4define(
"IL_MODE_ALIAS", 1);
 
    5define(
"IL_MODE_OUTPUT", 2);
 
    6define(
"IL_MODE_FULL", 3);
 
    8require_once(
"./Services/MediaObjects/classes/class.ilMediaItem.php");
 
    9include_once 
"./Services/Object/classes/class.ilObject.php";
 
   51        $this->
user = $DIC->user();
 
   52        $this->app_event_handler = 
$DIC[
"ilAppEventHandler"];
 
   53        $this->lng = 
$DIC->language();
 
   54        $this->is_alias = 
false;
 
   55        $this->media_items = array();
 
   56        $this->contains_int_link = 
false;
 
   63        $this->
ilias->raiseError(
"Operation ilObjMedia::setRefId() not allowed.", $this->
ilias->error_obj->FATAL);
 
   73        $this->
ilias->raiseError(
"Operation ilObjMedia::putInTree() not allowed.", $this->
ilias->error_obj->FATAL);
 
   78        $this->
ilias->raiseError(
"Operation ilObjMedia::createReference() not allowed.", $this->
ilias->error_obj->FATAL);
 
   83        parent::setTitle($a_title);
 
   88        return parent::getTitle();
 
   98    public static function _exists($a_id, $a_reference = 
false, $a_type = 
null)
 
  104        include_once(
"./Services/Link/classes/class.ilInternalLink.php");
 
  105        if (is_int(strpos($a_id, 
"_"))) {
 
  118    public function delete()
 
  121        $mob_logger->debug(
"ilObjMediaObject: Delete called for media object ID '" . $this->
getId() . 
"'.");
 
  123        if (!($this->
getId() > 0)) {
 
  129        $mob_logger->debug(
"ilObjMediaObject: ... Found " . count($usages) . 
" usages.");
 
  131        if (count($usages) == 0) {
 
  151            $mob_logger->debug(
"ilObjMediaObject: ... deleted.");
 
  153            foreach ($usages as $u) {
 
  154                $mob_logger->debug(
"ilObjMediaObject: ... usage type:" . $u[
"type"] .
 
  156                    ", lang:" . $u[
"lang"] .
 
  157                    ", hist_nr:" . $u[
"hist_nr"] . 
".");
 
  159            $mob_logger->debug(
"ilObjMediaObject: ... not deleted.");
 
  170        return parent::getDescription();
 
  178        parent::setDescription($a_description);
 
  194        include_once 
'Services/MetaData/classes/class.ilMD.php';
 
  196        switch ($a_element) {
 
  201                $md_gen = $md->getGeneral();
 
  203                if (is_object($md_gen)) {
 
  205                    $this->
setTitle($md_gen->getTitle());
 
  207                    foreach ($md_gen->getDescriptionIds() as 
$id) {
 
  208                        $md_des = $md_gen->getDescription(
$id);
 
  227        include_once 
'Services/MetaData/classes/class.ilMDCreator.php';
 
  232        $md_creator->setTitle($this->
getTitle());
 
  233        $md_creator->setTitleLanguage(
$ilUser->getPref(
'language'));
 
  235        $md_creator->setDescriptionLanguage(
$ilUser->getPref(
'language'));
 
  236        $md_creator->setKeywordLanguage(
$ilUser->getPref(
'language'));
 
  237        $md_creator->setLanguage(
$ilUser->getPref(
'language'));
 
  238        $md_creator->create();
 
  248        include_once(
"Services/MetaData/classes/class.ilMD.php");
 
  249        include_once(
"Services/MetaData/classes/class.ilMDGeneral.php");
 
  250        include_once(
"Services/MetaData/classes/class.ilMDDescription.php");
 
  253        $md_gen = $md->getGeneral();
 
  254        $md_gen->setTitle($this->
getTitle());
 
  257        $md_des_ids = $md_gen->getDescriptionIds();
 
  258        if (count($md_des_ids) > 0) {
 
  259            $md_des = $md_gen->getDescription($md_des_ids[0]);
 
  272        include_once(
'Services/MetaData/classes/class.ilMD.php');
 
  285        $this->media_items[] = $a_item;
 
  307        foreach ($this->media_items as $media_item) {
 
  308            if ($media_item->getPurpose() == $a_purpose) {
 
  321        foreach ($this->media_items as $key => $media_item) {
 
  322            if ($media_item->getPurpose() == $a_purpose) {
 
  323                unset($this->media_items[$key]);
 
  329        foreach ($this->media_items as $media_item) {
 
  331            $media_item->setMobId($this->
getId());
 
  332            $media_item->setNr(
$i);
 
  343        $this->media_items = array();
 
  349        for (
$i = 0; 
$i < count($this->media_items); 
$i++) {
 
  350            if ($this->media_items[
$i]->getPurpose() == $a_purpose) {
 
  397        $this->is_alias = $a_is_alias;
 
  407        return $this->origin_id = $a_id;
 
  432        $this->import_id = $a_id;
 
  438    public function create($a_create_meta_data = 
false, $a_save_media_items = 
true)
 
  442        if (!$a_create_meta_data) {
 
  446        if ($a_save_media_items) {
 
  450                $item->setMobId($this->
getId());
 
  451                $item->setNr(
$i + 1);
 
  459        $ilAppEventHandler->raise(
 
  460            'Services/MediaObjects',
 
  462            array(
'object' => $this,
 
  464            'obj_id' => $this->
getId())
 
  472    public function update($a_upload = 
false)
 
  488            if (is_object($item)) {
 
  489                $item->setMobId($this->
getId());
 
  491                if ($item->getLocationType() == 
"Reference") {
 
  492                    $item->extractUrlParameters();
 
  501        $ilAppEventHandler->raise(
 
  502            'Services/MediaObjects',
 
  504            array(
'object' => $this,
 
  506                    'obj_id' => $this->
getId())
 
  533        return "mobs/mm_" . $a_mob_id;
 
  564        $a_url_encode = 
false,
 
  577        $a_url_encode = 
false,
 
  581        if ($a_purpose == 
"") {
 
  582            $a_purpose = 
"Standard";
 
  585        if (preg_match(
"/https?\:/i", 
$location)) {
 
  607        if (!is_dir($path)) {
 
  608            $this->
ilias->raiseError(
"Failed to create directory $path.", $this->
ilias->error_obj->FATAL);
 
  629        $a_subdir = str_replace(
"..", 
"", $a_subdir);
 
  631        if ($a_subdir != 
"") {
 
  632            $dir .= 
"/" . $a_subdir;
 
  638            foreach ($entries as 
$e) {
 
  639                if (is_file($dir . 
"/" . 
$e[
"entry"]) && 
$e[
"entry"] != 
"." && 
$e[
"entry"] != 
"..") {
 
  640                    $files[] = 
$e[
"entry"];
 
  661                $xml = 
"<MediaObject>";
 
  662                $xml .= 
"<MediaAlias OriginId=\"il__mob_" . $this->
getId() . 
"\"/>";
 
  666                    $xml .= 
"<MediaAliasItem Purpose=\"" . $item->getPurpose() . 
"\">";
 
  669                    $width = ($item->getWidth() != 
"")
 
  670                        ? 
"Width=\"" . $item->getWidth() . 
"\"" 
  672                    $height = ($item->getHeight() != 
"")
 
  673                        ? 
"Height=\"" . $item->getHeight() . 
"\"" 
  675                    $halign = ($item->getHAlign() != 
"")
 
  676                        ? 
"HorizontalAlign=\"" . $item->getHAlign() . 
"\"" 
  678                    $xml .= 
"<Layout $width $height $halign />";
 
  681                    if ($item->getCaption() != 
"") {
 
  682                        $xml .= 
"<Caption Align=\"bottom\">" .
 
  687                    if ($item->getTextRepresentation() != 
"") {
 
  688                        $xml .= 
"<TextRepresentation>" .
 
  689                            $this->
escapeProperty($item->getTextRepresentation()) . 
"</TextRepresentation>";
 
  693                    $parameters = $item->getParameters();
 
  694                    foreach ($parameters as 
$name => $value) {
 
  695                        $xml .= 
"<Parameter Name=\"$name\" Value=\"" . $this->
escapeProperty($value) . 
"\"/>";
 
  697                    $xml .= $item->getMapAreasXML();
 
  698                    $xml .= 
"</MediaAliasItem>";
 
  707                $xml = 
"<MediaObject Id=\"il__mob_" . $this->
getId() . 
"\">";
 
  713                    $xml .= 
"<MediaItem Purpose=\"" . $item->getPurpose() . 
"\">";
 
  715                    if ($a_sign_locals && $item->getLocationType() == 
"LocalFile") {
 
  716                        require_once 
'Services/WebAccessChecker/classes/class.ilWACSignedPath.php';
 
  721                        if ($item->getLocationType() != 
"LocalFile") {  
 
  726                    $xml .= 
"<Location Type=\"" . $item->getLocationType() . 
"\">" .
 
  730                    $xml .= 
"<Format>" . $item->getFormat() . 
"</Format>";
 
  733                    $width = ($item->getWidth() != 
"")
 
  734                        ? 
"Width=\"" . $item->getWidth() . 
"\"" 
  736                    $height = ($item->getHeight() != 
"")
 
  737                        ? 
"Height=\"" . $item->getHeight() . 
"\"" 
  739                    $halign = ($item->getHAlign() != 
"")
 
  740                        ? 
"HorizontalAlign=\"" . $item->getHAlign() . 
"\"" 
  742                    $xml .= 
"<Layout $width $height $halign />";
 
  745                    if ($item->getCaption() != 
"") {
 
  746                        $xml .= 
"<Caption Align=\"bottom\">" .
 
  751                    if ($item->getTextRepresentation() != 
"") {
 
  752                        $xml .= 
"<TextRepresentation>" .
 
  753                            $this->
escapeProperty($item->getTextRepresentation()) . 
"</TextRepresentation>";
 
  763                    $parameters = $item->getParameters();
 
  764                    foreach ($parameters as 
$name => $value) {
 
  765                        $xml .= 
"<Parameter Name=\"$name\" Value=\"" . $this->
escapeProperty($value) . 
"\"/>";
 
  767                    $xml .= $item->getMapAreasXML();
 
  770                    if ($item->getPurpose() == 
"Standard") {
 
  772                        foreach ($srts as $srt) {
 
  775                            if (
$ilUser->getLanguage() != $meta_lang &&
 
  776                                $ilUser->getLanguage() == $srt[
"language"]) {
 
  777                                $def = 
' Default="true" ';
 
  779                            $xml .= 
"<Subtitle File=\"" . $srt[
"full_path"] .
 
  780                                "\" Language=\"" . $srt[
"language"] . 
"\" " . $def . 
"/>";
 
  783                    $xml .= 
"</MediaItem>";
 
  791                $xml = 
"<MediaObject>";
 
  794                include_once(
"Services/MetaData/classes/class.ilMD2XML.php");
 
  796                $md2xml->setExportMode(
true);
 
  797                $md2xml->startExport();
 
  798                $xml .= $md2xml->getXML();
 
  805                    $xml .= 
"<MediaItem Purpose=\"" . $item->getPurpose() . 
"\">";
 
  808                    $xml .= 
"<Location Type=\"" . $item->getLocationType() . 
"\">" .
 
  809                        $this->
handleAmps($item->getLocation()) . 
"</Location>";
 
  812                    $xml .= 
"<Format>" . $item->getFormat() . 
"</Format>";
 
  815                    $width = ($item->getWidth() != 
"")
 
  816                        ? 
"Width=\"" . $item->getWidth() . 
"\"" 
  818                    $height = ($item->getHeight() != 
"")
 
  819                        ? 
"Height=\"" . $item->getHeight() . 
"\"" 
  821                    $halign = ($item->getHAlign() != 
"")
 
  822                        ? 
"HorizontalAlign=\"" . $item->getHAlign() . 
"\"" 
  824                    $xml .= 
"<Layout $width $height $halign />";
 
  827                    if ($item->getCaption() != 
"") {
 
  828                        $xml .= 
"<Caption Align=\"bottom\">" .
 
  829                            str_replace(
"&", 
"&", $item->getCaption()) . 
"</Caption>";
 
  833                    if ($item->getTextRepresentation() != 
"") {
 
  834                        $xml .= 
"<TextRepresentation>" .
 
  835                            str_replace(
"&", 
"&", $item->getTextRepresentation()) . 
"</TextRepresentation>";
 
  839                    $parameters = $item->getParameters();
 
  840                    foreach ($parameters as 
$name => $value) {
 
  841                        $xml .= 
"<Parameter Name=\"$name\" Value=\"$value\"/>";
 
  843                    $xml .= $item->getMapAreasXML(
true, $a_inst);
 
  844                    $xml .= 
"</MediaItem>";
 
  848        $xml .= 
"</MediaObject>";
 
  860        return htmlspecialchars($a_value);
 
  869        $a_str = str_replace(
"&", 
"&", $a_str);
 
  870        $a_str = str_replace(
"&", 
"&", $a_str);
 
  896        ilUtil::rCopy($mobdir, $a_target_dir . 
"/objects/" . $subdir);
 
  903        $a_target_dir = $a_target_dir . 
"/objects/" . $subdir;
 
  906        $tpl->setCurrentBlock(
"ilMedia");
 
  914        require_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
 
  916        require_once(
"./Services/COPage/classes/class.ilPageObject.php");
 
  921        $xml .= $pg_obj->getMediaAliasElement($this->
getId());
 
  928        $xsl = file_get_contents(
"./Services/COPage/xsl/page.xsl");
 
  929        $args = array( 
'/_xml' => 
$xml, 
'/_xsl' => $xsl );
 
  936        $params = array(
'mode' => 
"fullscreen", 
'enlarge_path' => $enlarge_path,
 
  937            'link_params' => 
"ref_id=" . 
$_GET[
"ref_id"],
'fullscreen_link' => 
"",
 
  939            'ref_id' => 
$_GET[
"ref_id"], 
'webspace_path' => $wb_path);
 
  940        $output = xslt_process($xh, 
"arg:/_xml", 
"arg:/_xsl", 
null, $args, $params);
 
  945        include_once(
"./Services/MediaObjects/classes/class.ilPlayerUtil.php");
 
  946        $tpl->setVariable(
"LOCATION_CONTENT_STYLESHEET", 
"../../css/style.css");
 
  947        $tpl->setVariable(
"LOCATION_STYLESHEET", 
"../../css/system.css");
 
  948        $tpl->setVariable(
"MEDIA_CONTENT", $output);
 
  949        $output = 
$tpl->get();
 
  951        $output = preg_replace(
"/mobs\/mm_(\d+)\/([^\"]+)/i", 
"$2", $output);
 
  952        $output = preg_replace(
"/\.\/Services\/MediaObjects\/flash_mp3_player/i", 
"../../players", $output);
 
  954        $output = preg_replace(
"/file=..\/..\/..\//i", 
"file=../objects/" . $subdir . 
"/", $output);
 
  956        fwrite(fopen($a_target_dir . 
'/fullscreen.html', 
'w'), $output);
 
  961        if ($a_tag == 
"Identifier" && $a_param == 
"Entry") {
 
  981        $this->contains_int_link = $a_contains_link;
 
  996    public static function _deleteAllUsages($a_type, $a_id, $a_usage_hist_nr = 0, $a_lang = 
"-")
 
 1003        if ($a_usage_hist_nr !== 
false) {
 
 1004            $and_hist = 
" AND usage_hist_nr = " . 
$ilDB->quote($a_usage_hist_nr, 
"integer");
 
 1008        $set = 
$ilDB->query(
"SELECT id FROM mob_usage" .
 
 1009            " WHERE usage_type = " . 
$ilDB->quote($a_type, 
"text") .
 
 1010            " AND usage_id = " . 
$ilDB->quote($a_id, 
"integer") .
 
 1011            " AND usage_lang = " . 
$ilDB->quote($a_lang, 
"text") .
 
 1013        while ($row = 
$ilDB->fetchAssoc($set)) {
 
 1014            $mob_ids[] = $row[
"id"];
 
 1017        $q = 
"DELETE FROM mob_usage WHERE usage_type = " .
 
 1018            $ilDB->quote($a_type, 
"text") .
 
 1019            " AND usage_id= " . 
$ilDB->quote($a_id, 
"integer") .
 
 1020            " AND usage_lang = " . 
$ilDB->quote($a_lang, 
"text") .
 
 1022        $ilDB->manipulate($q);
 
 1024        foreach ($mob_ids as $mob_id) {
 
 1039        if ($a_lang != 
"") {
 
 1040            $lstr = 
" AND usage_lang = " . 
$ilDB->quote($a_lang, 
"text");
 
 1043        if ($a_usage_hist_nr !== 
false) {
 
 1044            $hist_str = 
" AND usage_hist_nr = " . 
$ilDB->quote($a_usage_hist_nr, 
"integer");
 
 1047        $q = 
"SELECT * FROM mob_usage WHERE " .
 
 1048            "usage_type = " . 
$ilDB->quote($a_type, 
"text") . 
" AND " .
 
 1049            "usage_id = " . 
$ilDB->quote($a_id, 
"integer") .
 
 1052        $mob_set = 
$ilDB->query($q);
 
 1053        while ($mob_rec = 
$ilDB->fetchAssoc($mob_set)) {
 
 1055                $mobs[$mob_rec[
"id"]] = $mob_rec[
"id"];
 
 1065    public static function _saveUsage($a_mob_id, $a_type, $a_id, $a_usage_hist_nr = 0, $a_lang = 
"-")
 
 1074                "id" => array(
"integer", (
int) $a_mob_id),
 
 1075                "usage_type" => array(
"text", $a_type),
 
 1076                "usage_id" => array(
"integer", $a_id),
 
 1077                "usage_lang" => array(
"text", $a_lang),
 
 1078                "usage_hist_nr" => array(
"integer", (
int) $a_usage_hist_nr)
 
 1089    public static function _removeUsage($a_mob_id, $a_type, $a_id, $a_usage_hist_nr = 0, $a_lang = 
"-")
 
 1095        $q = 
"DELETE FROM mob_usage WHERE " .
 
 1096            " id = " . 
$ilDB->quote((
int) $a_mob_id, 
"integer") . 
" AND " .
 
 1097            " usage_type = " . 
$ilDB->quote($a_type, 
"text") . 
" AND " .
 
 1098            " usage_id = " . 
$ilDB->quote((
int) $a_id, 
"integer") . 
" AND " .
 
 1099            " usage_lang = " . 
$ilDB->quote($a_lang, 
"text") . 
" AND " .
 
 1100            " usage_hist_nr = " . 
$ilDB->quote((
int) $a_usage_hist_nr, 
"integer");
 
 1101        $ilDB->manipulate($q);
 
 1126        if ($a_include_history) {
 
 1127            $hist_str = 
", usage_hist_nr";
 
 1131        $q = 
"SELECT DISTINCT usage_type, usage_id, usage_lang" . $hist_str . 
" FROM mob_usage WHERE id = " .
 
 1132            $ilDB->quote($a_id, 
"integer");
 
 1134        if (!$a_include_history) {
 
 1135            $q .= 
" AND usage_hist_nr = " . 
$ilDB->quote(0, 
"integer");
 
 1138        $us_set = 
$ilDB->query($q);
 
 1140        while ($us_rec = 
$ilDB->fetchAssoc($us_set)) {
 
 1142            if (is_int(strpos($us_rec[
"usage_type"], 
":"))) {
 
 1143                $us_arr = explode(
":", $us_rec[
"usage_type"]);
 
 1151                include_once(
"./Services/COPage/classes/class.ilPageObject.php");
 
 1158                $ret[] = array(
"type" => $us_rec[
"usage_type"],
 
 1159                    "id" => $us_rec[
"usage_id"],
 
 1160                    "lang" => $us_rec[
"usage_lang"],
 
 1161                    "hist_nr" => $us_rec[
"usage_hist_nr"]);
 
 1166        $q = 
"SELECT DISTINCT mep_id FROM mep_tree JOIN mep_item ON (child = obj_id) WHERE mep_item.foreign_id = " .
 
 1167            $ilDB->quote($a_id, 
"integer") . 
" AND mep_item.type = " . 
$ilDB->quote(
"mob", 
"text");
 
 1168        $us_set = 
$ilDB->query($q);
 
 1169        while ($us_rec = 
$ilDB->fetchAssoc($us_set)) {
 
 1170            $ret[] = array(
"type" => 
"mep",
 
 1171                "id" => $us_rec[
"mep_id"]);
 
 1175        include_once(
"./Services/News/classes/class.ilNewsItem.php");
 
 1177        foreach ($news_usages as $nu) {
 
 1183        $q = 
"SELECT DISTINCT mob_id FROM media_item it, map_area area " .
 
 1184            " WHERE area.item_id = it.id " .
 
 1185            " AND area.link_type = " . 
$ilDB->quote(
"int", 
"text") . 
" " .
 
 1186            " AND area.target = " . 
$ilDB->quote(
"il__mob_" . $a_id, 
"text");
 
 1187        $us_set = 
$ilDB->query($q);
 
 1188        while ($us_rec = 
$ilDB->fetchAssoc($us_set)) {
 
 1189            $ret[] = array(
"type" => 
"map",
 
 1190                "id" => $us_rec[
"mob_id"]);
 
 1195        foreach ($users as 
$user) {
 
 1196            $ret[] = array(
"type" => 
"clip",
 
 1210        if (is_int(strpos($a_usage[
"type"], 
":"))) {
 
 1211            $us_arr = explode(
":", $a_usage[
"type"]);
 
 1213            $cont_type = $us_arr[0];
 
 1215            $type = $a_usage[
"type"];
 
 1218        $id = $a_usage[
"id"];
 
 1225                switch ($cont_type) {
 
 1228                        include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
 
 1230                        if ($qinfo[
"original_id"] > 0) {
 
 1231                            include_once(
"./Modules/Test/classes/class.ilObjTest.php");
 
 1234                            $obj_id = $qinfo[
"obj_fi"];         
 
 1242                            $parent_id = $quest->getObjId();
 
 1245                            if ($quest->getOriginalId() &&
 
 1251                                $obj_id = $parent_id;
 
 1260                        $returned_pk = $a_usage[
'id'];
 
 1262                        include_once 
'Modules/Exercise/classes/class.ilExSubmission.php';
 
 1268                        $post_pk = $a_usage[
'id'];
 
 1269                        include_once 
'Modules/Forum/classes/class.ilForumPost.php';
 
 1270                        include_once 
'Modules/Forum/classes/class.ilForum.php';
 
 1272                        $frm_pk = $oPost->getForumId();
 
 1278                        $draft_id = $a_usage[
'id'];
 
 1279                        include_once 
'Modules/Forum/classes/class.ilForumPostDraft.php';
 
 1280                        include_once 
'Modules/Forum/classes/class.ilForum.php';
 
 1283                        $frm_pk = $oDraft->getForumId();
 
 1287                        $history_id = $a_usage[
'id'];
 
 1288                        include_once 
'Modules/Forum/classes/class.ilForumDraftsHistory.php';
 
 1289                        include_once 
'Modules/Forum/classes/class.ilForumPostDraft.php';
 
 1290                        include_once 
'Modules/Forum/classes/class.ilForum.php';
 
 1294                        $frm_pk = $oDraft->getForumId();
 
 1300                        $obj_id = $a_usage[
'id'];
 
 1318                switch ($cont_type) {
 
 1321                        include_once(
'./Services/COPage/classes/class.ilPageObject.php');
 
 1328                        include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
 
 1330                        if ($qinfo[
"original_id"] > 0) {
 
 1331                            include_once(
"./Modules/Test/classes/class.ilObjTest.php");
 
 1334                            $obj_id = $qinfo[
"obj_fi"];         
 
 1337                            include_once(
"./Services/COPage/classes/class.ilPCQuestion.php");
 
 1339                            if ($pinfo && $pinfo[
"parent_type"] == 
"lm") {
 
 1340                                include_once(
"./Modules/LearningModule/classes/class.ilLMObject.php");
 
 1344                            if ($pinfo && $pinfo[
"parent_type"] == 
"sahs") {
 
 1345                                include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Node.php");
 
 1353                        include_once(
"./Modules/LearningModule/classes/class.ilLMObject.php");
 
 1365                        include_once 
'Modules/Wiki/classes/class.ilWikiPage.php';
 
 1372                        include_once(
'./Services/COPage/classes/class.ilPageObject.php');
 
 1378                        include_once 
"Modules/Portfolio/classes/class.ilPortfolioPage.php";
 
 1384                        include_once 
"Modules/Portfolio/classes/class.ilPortfolioTemplatePage.php";
 
 1390                        include_once(
'./Services/COPage/classes/class.ilPageObject.php');
 
 1419                include_once(
"./Services/News/classes/class.ilNewsItem.php");
 
 1434    public static function _resizeImage($a_file, $a_width, $a_height, $a_constrain_prop = 
false)
 
 1436        $file_path = pathinfo($a_file);
 
 1437        $location = substr($file_path[
"basename"], 0, strlen($file_path[
"basename"]) -
 
 1438            strlen($file_path[
"extension"]) - 1) . 
"_" .
 
 1440            $a_height . 
"." . $file_path[
"extension"];
 
 1441        $target_file = $file_path[
"dirname"] . 
"/" .
 
 1463        include_once(
"./Services/Utilities/classes/class.ilMimeTypeUtil.php");
 
 1476        $a_constrain_proportions,
 
 1490        if ($a_format == 
"audio/mpeg") {
 
 1495            include_once(
"./Services/MediaObjects/classes/class.ilMediaImageUtil.php");
 
 1496            if ($a_type == 
"File") {
 
 1503        if ($a_use_original) {
 
 1510                $info = 
$lng->txt(
"cont_could_not_determine_resource_size");
 
 1513            $w = (int) $a_user_width;
 
 1514            $h = (int) $a_user_height;
 
 1521                        $wr = 
$size[0] / $w;
 
 1524                        $hr = 
$size[1] / $h;
 
 1530                        $width = (int) round(
$size[0] / $r);
 
 1531                        $height = (int) round(
$size[1] / $r);
 
 1539        if ($width == 0 && $a_user_width === 
"") {
 
 1542        if ($height == 0 && $a_user_height === 
"") {
 
 1545        return array(
"width" => $width, 
"height" => $height, 
"info" => $info);
 
 1560        $media_object->setTitle(
$name);
 
 1561        $media_object->setDescription(
"");
 
 1562        $media_object->create();
 
 1565        $media_object->createDirectory();
 
 1569        $media_object->addMediaItem($media_item);
 
 1570        $media_item->setPurpose(
"Standard");
 
 1572        $file = $mob_dir . 
"/" . 
$name;
 
 1576            copy($tmp_name, $file);
 
 1582        $media_item->setFormat(
$format);
 
 1584        $media_item->setLocationType(
"LocalFile");
 
 1585        $media_object->setTitle(
$name);
 
 1586        $media_object->setDescription(
$format);
 
 1589            include_once(
"./Services/MediaObjects/classes/class.ilMediaImageUtil.php");
 
 1591            $media_item->setWidth(
$size[0]);
 
 1592            $media_item->setHeight(
$size[1]);
 
 1594        $media_item->setHAlign(
"Left");
 
 1597        include_once(
"./Services/MediaObjects/classes/class.ilMediaSvgSanitizer.php");
 
 1600        $media_object->update();
 
 1602        return $media_object;
 
 1610        $a_subdir = str_replace(
"..", 
"", $a_subdir);
 
 1612        if ($a_subdir != 
"") {
 
 1613            $dir .= 
"/" . $a_subdir;
 
 1616        if ($a_mode == 
"rename") {
 
 1617            rename($tmp_name, $dir . 
"/" . $a_name);
 
 1622        include_once(
"./Services/MediaObjects/classes/class.ilMediaSvgSanitizer.php");
 
 1632    public function uploadSrtFile($a_tmp_name, $a_language, $a_mode = 
"move_uploaded")
 
 1634        if (is_file($a_tmp_name) && $a_language != 
"") {
 
 1648        if (!is_dir($srt_dir)) {
 
 1654        $srt_files = array();
 
 1655        foreach ($items as 
$i) {
 
 1656            if (!in_array(
$i[
"entry"], array(
".", 
"..")) && 
$i[
"type"] == 
"file") {
 
 1657                $name = explode(
".", 
$i[
"entry"]);
 
 1658                if (
$name[1] == 
"srt" && substr(
$name[0], 0, 9) == 
"subtitle_") {
 
 1659                    $srt_files[] = array(
"file" => 
$i[
"entry"],
 
 1660                        "full_path" => 
"srt/" . 
$i[
"entry"], 
"language" => substr(
$name[0], 9, 2));
 
 1677        $size = (int) $a_size;
 
 1680        $file = $m_dir . 
"/" . $a_file;
 
 1686        if (
$size > (
int) $wh[0] && 
$size > $wh[1]) {
 
 1694            $m_dir . 
"/" . $a_file,
 
 1695            $t_dir . 
"/" . $a_thumbname,
 
 1710        return $t_dir . 
"/" . $a_thumbname;
 
 1719        $file = str_replace(
"..", 
"", $a_file);
 
 1721        if (is_file($file)) {
 
 1734        if (!is_array($a_ignore)) {
 
 1735            $a_ignore = array();
 
 1741        foreach ($med_items as $med_item) {
 
 1743            foreach ($int_links as $k => $int_link) {
 
 1744                if ($int_link[
"Type"] == 
"MediaObject") {
 
 1745                    include_once(
"./Services/Link/classes/class.ilInternalLink.php");
 
 1748                        if (!in_array($l_id, $linked) &&
 
 1749                            !in_array($l_id, $a_ignore)) {
 
 1765        return array_filter(self::getAllowedFileTypes(), 
function ($v) {
 
 1766            return !in_array($v, self::getForbiddenFileTypes());
 
 1778        if (trim($mset->get(
"black_list_file_types")) == 
"") {
 
 1783                return strtolower(trim($v));
 
 1785            explode(
",", $mset->get(
"black_list_file_types"))
 
 1797        if (trim($mset->get(
"restricted_file_types")) == 
"") {
 
 1802                return strtolower(trim($v));
 
 1804            explode(
",", $mset->get(
"restricted_file_types"))
 
 1816        if (in_array($a_type, self::getForbiddenFileTypes())) {
 
 1819        if (count(self::getAllowedFileTypes()) == 0 || in_array($a_type, self::getAllowedFileTypes())) {
 
 1832        $new_obj->setTitle($this->
getTitle());
 
 1837            $new_obj->addMediaItem($val);
 
 1840        $new_obj->create(
false, 
true);
 
 1843        $new_obj->createDirectory();
 
 1855        include_once(
"Services/MetaData/classes/class.ilMD.php");
 
 1856        $md = 
new ilMD(0, $this->
getId(), 
"mob");
 
 1857        $new_md = $md->cloneMD(0, $new_obj->getId(), 
"mob");
 
 1875        $pi = pathinfo($a_prevpic[
"name"]);
 
 1876        $ext = $pi[
"extension"];
 
 1877        if (in_array($ext, array(
"jpg", 
"jpeg", 
"png"))) {
 
 1888    public function generatePreviewPic($a_width, $a_height, $sec = 1)
 
 1891        if ($item->getFormat() === 
"image/svg+xml") {
 
 1895        if ($item->getLocationType() == 
"LocalFile") {
 
 1896            if (is_int(strpos($item->getFormat(), 
"image/"))) {
 
 1898                $file = $dir . 
"/" .
 
 1899                    $item->getLocation();
 
 1900                if (is_file($file)) {
 
 1905                            ) . 
"[0] -geometry " . $a_width . 
"x" . $a_height . 
"^ -gravity center -extent " . $a_width . 
"x" . $a_height . 
" PNG:" . $dir . 
"/mob_vpreview.png" 
 1913            if (is_int(strpos($item->getFormat(), 
"video/"))) {
 
 1921                    include_once(
"./Services/MediaObjects/classes/class.ilFFmpeg.php");
 
 1934                    if (is_array(
$ret) && count(
$ret) > 0) {
 
 1939                    $logger = 
$GLOBALS[
'DIC']->logger()->mob();
 
 1940                    $logger->warning(
$e->getMessage() . 
$message);
 
 1956        $ppics = array(
"mob_vpreview.jpg",
 
 1957            "mob_vpreview.jpeg",
 
 1958            "mob_vpreview.png");
 
 1959        foreach ($ppics as $p) {
 
 1960            if (is_file($dir . 
"/" . $p)) {
 
 1961                if ($a_filename_only) {
 
 1964                    return $dir . 
"/" . $p;
 
 1981        $rchars = array(
"`", 
"=", 
"$", 
"{", 
"}", 
"'", 
";", 
" ", 
"(", 
")");
 
 1982        $a_name = str_replace($rchars, 
"_", $a_name);
 
 1983        $a_name = str_replace(
"__", 
"_", $a_name);
 
 2011        include_once(
"./Services/MediaObjects/exceptions/class.ilMediaObjectsException.php");
 
 2012        if (!is_file($a_file[
"tmp_name"])) {
 
 2038        include_once(
"./Services/MetaData/classes/class.ilMDLanguageItem.php");
 
 2043        foreach ($files as $k => 
$i) {
 
 2045            if (
$i[
"type"] == 
"file" && !in_array($k, array(
".", 
".."))) {
 
 2046                if (pathinfo($k, PATHINFO_EXTENSION) == 
"srt") {
 
 2048                    if (substr($k, strlen($k) - 7, 1) == 
"_") {
 
 2049                        $lang = substr($k, strlen($k) - 6, 2);
 
 2050                        if (!in_array(
$lang, $lang_codes)) {
 
 2054                    $items[] = array(
"filename" => $k, 
"lang" => 
$lang);
 
 2069        if (!self::isTypeAllowed(
"html")) {
 
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
An exception for terminatinating execution or to throw for unit testing.
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
static _lookupSurveyObjId($a_question_id)
static _getQuestionInfo($question_id)
Returns question information from the database.
static lookupExerciseIdForReturnedId($a_returned_id)
Get exercise from submission id (used in ilObjMediaObject)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getLastReturnValues()
Get last return values.
static extractImage( $a_file, $a_target_filename, $a_target_dir="", $a_sec=1)
Extract image from video file.
Class ilForumDraftHistory.
static newInstanceByDraftId($draft_id)
static _lookupObjIdForForumId($a_for_id)
special template class to simplify handling of ITX/PEAR
static _lookupTermId($a_def_id)
Looks up term id for a definition id.
static _lookGlossaryID($term_id)
get glossary id form term id
static _extractObjIdOfTarget($a_target)
Extract object id out of target.
static _lookupContObjID($a_id)
get learning module / digibook id for lm object
static getLogger($a_component_id)
Get component logger.
static _getPossibleLanguageCodes()
static _getIntLinks($a_item_id)
get all internal links of a media items map areas
const APPLICATION__OCTET_STREAM
static lookupMimeType($path_to_file, $fallback=self::APPLICATION__OCTET_STREAM, $a_external=null)
static _lookupContextObjId($a_news_id)
Context Object ID.
static _lookupMediaObjectUsages($a_mob_id)
Lookup media object usage(s)
static _lookupTestObjIdForQuestionId($a_q_id)
Get test Object ID for question ID.
static _getUsersForClipboadObject($a_type, $a_id)
get all users, that have a certain object within their clipboard
Class ilObject Basic functions for all objects.
getType()
get object type @access public
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data@access public
getId()
get object id @access public
static _writeTitle($a_obj_id, $a_title)
write title to db (static)
static _lookupType($a_id, $a_reference=false)
lookup object type
static _writeDescription($a_obj_id, $a_desc)
write description to db (static)
static _getPageForQuestionId($a_q_id, $a_parent_type="")
Get page for question id.
static lookupParentId($a_id, $a_type)
Lookup parent id.
static _exists($a_parent_type, $a_id, $a_lang="", $a_no_cache=false)
Checks whether page exists.
static getFlashVideoPlayerDirectory()
Get flash video player directory.
static findPortfolioForPage($a_page_id)
Get portfolio id of page id.
static _lookupSLMID($a_id)
Lookup Scorm Learning Module ID for node id.
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static convertImage( $a_from, $a_to, $a_target_format="", $a_geometry="", $a_background_color="")
convert image
static isConvertVersionAtLeast($a_version)
Compare convert version numbers.
static insertInstIntoID($a_value)
inserts installation id into ILIAS id
static escapeShellArg($a_arg)
static getWebspaceDir($mode="filesystem")
get webspace directory
static execConvert($args)
execute convert command
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
static resizeImage($a_from, $a_to, $a_width, $a_height, $a_constrain_prop=false)
resize image
static getDir($a_dir, $a_rec=false, $a_sub_dir="")
get directory
static rRenameSuffix(string $a_dir, string $a_old_suffix, string $a_new_suffix)
Renames all files with certain suffix and gives them a new suffix.
static unzip(string $path_to_zip_file, bool $overwrite_existing=false, bool $unpack_flat=false)
static getASCIIFilename($a_filename)
convert utf8 to ascii filename
static getHtmlPath($relative_path)
get url of path
static makeDirParents($a_dir)
Create a new directory and all parent directories.
static deducibleSize($a_mime)
checks if mime type is provided by getimagesize()
static secureUrl($url)
Prepare secure href attribute.
static createDirectory($a_dir, $a_mod=0755)
create directory
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
static renameExecutables($a_dir)
Rename uploaded executables for security reasons.
static signFile($path_to_file)
static lookupObjIdByPage($a_page_id)
returns the wiki/object id to a given page id
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
redirection script todo: (a better solution should control the processing via a xml file)