当前位置: 首页>>代码示例>>PHP>>正文


PHP ilObjMediaObject::getMimeType方法代码示例

本文整理汇总了PHP中ilObjMediaObject::getMimeType方法的典型用法代码示例。如果您正苦于以下问题:PHP ilObjMediaObject::getMimeType方法的具体用法?PHP ilObjMediaObject::getMimeType怎么用?PHP ilObjMediaObject::getMimeType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ilObjMediaObject的用法示例。


在下文中一共展示了ilObjMediaObject::getMimeType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ilObjMediaObject

 /**
  * Create new media object and update page in db and return new media object
  */
 function &_saveTempFileAsMediaObject($name, $tmp_name, $upload = TRUE)
 {
     // create dummy object in db (we need an id)
     $media_object = new ilObjMediaObject();
     $media_object->setTitle($name);
     $media_object->setDescription("");
     $media_object->create();
     // determine and create mob directory, move uploaded file to directory
     $media_object->createDirectory();
     $mob_dir = ilObjMediaObject::_getDirectory($media_object->getId());
     $media_item =& new ilMediaItem();
     $media_object->addMediaItem($media_item);
     $media_item->setPurpose("Standard");
     $file = $mob_dir . "/" . $name;
     if ($upload) {
         ilUtil::moveUploadedFile($tmp_name, $name, $file);
     } else {
         copy($tmp_name, $file);
     }
     // get mime type
     $format = ilObjMediaObject::getMimeType($file);
     $location = $name;
     // set real meta and object data
     $media_item->setFormat($format);
     $media_item->setLocation($location);
     $media_item->setLocationType("LocalFile");
     $media_object->setTitle($name);
     $media_object->setDescription($format);
     if (ilUtil::deducibleSize($format)) {
         $size = getimagesize($file);
         $media_item->setWidth($size[0]);
         $media_item->setHeight($size[1]);
     }
     $media_item->setHAlign("Left");
     ilUtil::renameExecutables($mob_dir);
     $media_object->update();
     return $media_object;
 }
开发者ID:Walid-Synakene,项目名称:ilias,代码行数:41,代码来源:class.ilObjMediaObject.php

示例2: getMimetype

 /**
  * estimate content type for a filename by extension
  * first do it for common static web files from external list
  * if not found peek into file by slow php function mime_content_type()
  * @param $filename required
  * @return string mimetype name e.g. image/jpeg
  */
 public function getMimetype($filename)
 {
     include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
     return ilObjMediaObject::getMimeType($filename);
 }
开发者ID:bheyser,项目名称:qplskl,代码行数:12,代码来源:ilSCORM13Player.php

示例3: updateMediaItem

 /**
  * update media item from form
  *
  * @param IlObjectMediaObject $mob
  * @param IlMediaItem $mediaItem
  * @return string file
  */
 private function updateMediaItem($mob, &$mediaItem)
 {
     $purpose = $mediaItem->getPurpose();
     $url_gui = $this->form_gui->getInput("url_" . $purpose);
     $file_gui = $this->form_gui->getInput("file_" . $purpose);
     if ($url_gui) {
         // http
         $file = $this->form_gui->getInput("url_" . $purpose);
         $title = basename($file);
         $location = $this->form_gui->getInput("url_" . $purpose);
         $locationType = "Reference";
     } elseif ($file_gui["size"] > 0) {
         // lokal
         // determine and create mob directory, move uploaded file to directory
         $mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
         if (!is_dir($mob_dir)) {
             $mob->createDirectory();
         }
         $file_name = ilUtil::getASCIIFilename($_FILES['file_' . $purpose]['name']);
         $file_name = str_replace(" ", "_", $file_name);
         $file = $mob_dir . "/" . $file_name;
         $title = $file_name;
         $locationType = "LocalFile";
         $location = $title;
         ilUtil::moveUploadedFile($_FILES['file_' . $purpose]['tmp_name'], $file_name, $file);
         ilUtil::renameExecutables($mob_dir);
     }
     // check if not automatic mimetype detection
     if ($_POST["mimetype_" . $purpose] != "") {
         $mediaItem->setFormat($_POST["mimetype_" . $purpose]);
     } elseif ($mediaItem->getLocation() != "") {
         $format = ilObjMediaObject::getMimeType($mediaItem->getLocation());
         $mediaItem->setFormat($format);
     }
     if (isset($file)) {
         // get mime type, if not already set!
         if (!isset($format)) {
             $format = ilObjMediaObject::getMimeType($file);
         }
         // set real meta and object data
         $mediaItem->setFormat($format);
         $mediaItem->setLocation($location);
         $mediaItem->setLocationType($locationType);
         $mediaItem->setHAlign("Left");
         $mediaItem->setHeight(self::isAudio($format) ? 0 : 180);
     }
     if ($purpose == "Standard") {
         if (isset($title)) {
             $mob->setTitle($title);
         }
         if (isset($format)) {
             $mob->setDescription($format);
         }
     }
     return $file;
 }
开发者ID:khanhnnvn,项目名称:ilias_E-learning,代码行数:63,代码来源:class.ilObjMediaCastGUI.php

示例4: deliverVCard

 /**
  * Deliver vcard information.
  */
 function deliverVCard()
 {
     // get user object
     if (!ilObject::_exists($this->getUserId())) {
         return "";
     }
     $user = new ilObjUser($this->getUserId());
     require_once "./Services/User/classes/class.ilvCard.php";
     $vcard = new ilvCard();
     // ilsharedresourceGUI: embedded in shared portfolio
     if ($user->getPref("public_profile") != "y" && $user->getPref("public_profile") != "g" && $_GET["baseClass"] != "ilsharedresourceGUI") {
         return;
     }
     $vcard->setName($user->getLastName(), $user->getFirstName(), "", $user->getUTitle());
     $vcard->setNickname($user->getLogin());
     $webspace_dir = ilUtil::getWebspaceDir("output");
     $imagefile = $webspace_dir . "/usr_images/" . $user->getPref("profile_image");
     if ($user->getPref("public_upload") == "y" && @is_file($imagefile)) {
         $fh = fopen($imagefile, "r");
         if ($fh) {
             $image = fread($fh, filesize($imagefile));
             fclose($fh);
             require_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
             $mimetype = ilObjMediaObject::getMimeType($imagefile);
             if (preg_match("/^image/", $mimetype)) {
                 $type = $mimetype;
             }
             $vcard->setPhoto($image, $type);
         }
     }
     $val_arr = array("getInstitution" => "institution", "getDepartment" => "department", "getStreet" => "street", "getZipcode" => "zipcode", "getCity" => "city", "getCountry" => "country", "getPhoneOffice" => "phone_office", "getPhoneHome" => "phone_home", "getPhoneMobile" => "phone_mobile", "getFax" => "fax", "getEmail" => "email", "getHobby" => "hobby", "getMatriculation" => "matriculation", "getClientIP" => "client_ip");
     $org = array();
     $adr = array();
     foreach ($val_arr as $key => $value) {
         // if value "y" show information
         if ($user->getPref("public_" . $value) == "y") {
             switch ($value) {
                 case "institution":
                     $org[0] = $user->{$key}();
                     break;
                 case "department":
                     $org[1] = $user->{$key}();
                     break;
                 case "street":
                     $adr[2] = $user->{$key}();
                     break;
                 case "zipcode":
                     $adr[5] = $user->{$key}();
                     break;
                 case "city":
                     $adr[3] = $user->{$key}();
                     break;
                 case "country":
                     $adr[6] = $user->{$key}();
                     break;
                 case "phone_office":
                     $vcard->setPhone($user->{$key}(), TEL_TYPE_WORK);
                     break;
                 case "phone_home":
                     $vcard->setPhone($user->{$key}(), TEL_TYPE_HOME);
                     break;
                 case "phone_mobile":
                     $vcard->setPhone($user->{$key}(), TEL_TYPE_CELL);
                     break;
                 case "fax":
                     $vcard->setPhone($user->{$key}(), TEL_TYPE_FAX);
                     break;
                 case "email":
                     $vcard->setEmail($user->{$key}());
                     break;
                 case "hobby":
                     $vcard->setNote($user->{$key}());
                     break;
             }
         }
     }
     if (count($org)) {
         $vcard->setOrganization(join(";", $org));
     }
     if (count($adr)) {
         $vcard->setAddress($adr[0], $adr[1], $adr[2], $adr[3], $adr[4], $adr[5], $adr[6]);
     }
     ilUtil::deliverData(utf8_decode($vcard->buildVCard()), $vcard->getFilename(), $vcard->getMimetype());
 }
开发者ID:Walid-Synakene,项目名称:ilias,代码行数:87,代码来源:class.ilPublicUserProfileGUI.php

示例5: deliverFile

 /**
  * store delivered file in filesystem
  * @param array HTTP_POST_FILES
  * @param numeric database id of the user who delivered the file
  * @access	public
  * @return mixed Returns a result array with filename and mime type of the saved file, otherwise false
  */
 function deliverFile($a_http_post_file, $user_id, $is_unziped = false)
 {
     $this->create();
     // TODO:
     // CHECK UPLOAD LIMIT
     //
     $result = false;
     if (isset($a_http_post_file) && $a_http_post_file['size']) {
         $filename = $a_http_post_file['name'];
         // replace whitespaces with underscores
         $filename = preg_replace("/\\s/", "_", $filename);
         // remove all special characters
         $filename = preg_replace("/[^_a-zA-Z0-9\\.]/", "", $filename);
         if (!is_dir($savepath = $this->getAbsoluteSubmissionPath())) {
             ilUtil::makeDir($savepath);
         }
         $savepath .= '/' . $user_id;
         if (!is_dir($savepath)) {
             ilUtil::makeDir($savepath);
         }
         // CHECK IF FILE PATH EXISTS
         if (!is_dir($savepath)) {
             require_once "./Services/Utilities/classes/class.ilUtil.php";
             #ilUtil::makeDirParents($savepath);
             ilUtil::makeDir($savepath);
         }
         $now = getdate();
         $prefix = sprintf("%04d%02d%02d%02d%02d%02d", $now["year"], $now["mon"], $now["mday"], $now["hours"], $now["minutes"], $now["seconds"]);
         if (!$is_unziped) {
             //move_uploaded_file($a_http_post_file["tmp_name"], $savepath . $prefix . "_" . $filename);
             ilUtil::moveUploadedFile($a_http_post_file["tmp_name"], $a_http_post_file["name"], $savepath . "/" . $prefix . "_" . $filename);
         } else {
             rename($a_http_post_file['tmp_name'], $savepath . "/" . $prefix . "_" . $filename);
         }
         require_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
         if (is_file($savepath . "/" . $prefix . "_" . $filename)) {
             $result = array("filename" => $prefix . "_" . $filename, "fullname" => $savepath . "/" . $prefix . "_" . $filename, "mimetype" => ilObjMediaObject::getMimeType($savepath . "/" . $prefix . "_" . $filename));
         }
     }
     return $result;
 }
开发者ID:Walid-Synakene,项目名称:ilias,代码行数:48,代码来源:class.ilFSStorageExercise.php

示例6: uploadRoomsAgreement

 /**
  * Uploads a new rooms agreement by using the ILIAS MediaObject Service.
  * If the old file id is given, the old file will be deleted.
  *
  * @param array  $a_newfile   an array containing the input values of the form
  * @param string $a_oldFileId to delete trash
  *
  * @return string uploaded file id
  */
 public function uploadRoomsAgreement($a_newfile, $a_oldFileId = "0")
 {
     if (!empty($a_oldFileId) && $a_oldFileId != "0") {
         $agreementFile = new ilObjMediaObject($a_oldFileId);
         $agreementFile->delete();
     }
     $mediaObj = new ilObjMediaObject();
     $mediaObj->setTitle("RoomSharingRoomsAgreement");
     $mediaObj->setDescription("RoomSharingRoomsAgreement");
     $mediaObj->create();
     $mob_dir = ilObjMediaObject::_getDirectory($mediaObj->getId());
     if (!is_dir($mob_dir)) {
         $mediaObj->createDirectory();
     }
     $file_name = ilUtil::getASCIIFilename($a_newfile["name"]);
     $file_name_mod = str_replace(" ", "_", $file_name);
     $file = $mob_dir . "/" . $file_name_mod;
     ilUtil::moveUploadedFile($a_newfile["tmp_name"], $file_name_mod, $file);
     ilUtil::renameExecutables($mob_dir);
     $format = ilObjMediaObject::getMimeType($file);
     $media_item = new ilMediaItem();
     $mediaObj->addMediaItem($media_item);
     $media_item->setPurpose("Standard");
     $media_item->setFormat($format);
     $media_item->setLocation($file_name_mod);
     $media_item->setLocationType("LocalFile");
     $mediaObj->update();
     return $mediaObj->getId();
 }
开发者ID:studer-raimann,项目名称:RoomSharing,代码行数:38,代码来源:class.ilObjRoomSharing.php

示例7: createMediaFromUploadDir

 /**
  * Create media object from upload directory
  */
 function createMediaFromUploadDir()
 {
     $mset = new ilSetting("mobs");
     $upload_dir = trim($mset->get("upload_dir"));
     include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
     if (is_array($_POST["file"]) && ilMainMenuGUI::_checkAdministrationPermission()) {
         foreach ($_POST["file"] as $f) {
             $f = str_replace("..", "", $f);
             $fullpath = $upload_dir . "/" . $f;
             $mob = new ilObjMediaObject();
             $mob->setTitle(basename($fullpath));
             $mob->setDescription("");
             $mob->create();
             // determine and create mob directory, move uploaded file to directory
             //$mob_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$a_mob->getId();
             $mob->createDirectory();
             $mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
             $media_item = new ilMediaItem();
             $mob->addMediaItem($media_item);
             $media_item->setPurpose("Standard");
             $file = $mob_dir . "/" . basename($fullpath);
             ilUtil::moveUploadedFile($fullpath, basename($fullpath), $file, false, $_POST["action"]);
             // get mime type
             $format = ilObjMediaObject::getMimeType($file);
             $location = basename($fullpath);
             // set real meta and object data
             $media_item->setFormat($format);
             $media_item->setLocation($location);
             $media_item->setLocationType("LocalFile");
             $mob->setDescription($format);
             // determine width and height of known image types
             $wh = ilObjMediaObject::_determineWidthHeight(500, 400, $format, "File", $mob_dir . "/" . $location, $media_item->getLocation(), true, true, "", "");
             $media_item->setWidth($wh["width"]);
             $media_item->setHeight($wh["height"]);
             if ($wh["info"] != "") {
                 //				ilUtil::sendInfo($wh["info"], true);
             }
             $media_item->setHAlign("Left");
             ilUtil::renameExecutables($mob_dir);
             $mob->update();
             // put it into current folder
             $mep_item = new ilMediaPoolItem();
             $mep_item->setTitle($mob->getTitle());
             $mep_item->setType("mob");
             $mep_item->setForeignId($mob->getId());
             $mep_item->create();
             $tree = $this->object->getTree();
             $parent = $_GET["mepitem_id"] == "" ? $tree->getRootId() : $_GET["mepitem_id"];
             $tree->insertNode($mep_item->getId(), $parent);
         }
     }
     ilUtil::redirect("ilias.php?baseClass=ilMediaPoolPresentationGUI&cmd=listMedia&ref_id=" . $_GET["ref_id"] . "&mepitem_id=" . $_GET["mepitem_id"]);
 }
开发者ID:khanhnnvn,项目名称:ilias_E-learning,代码行数:56,代码来源:class.ilObjMediaPoolGUI.php

示例8: createFile

 /**
  * Creates and inserts file object into tree
  *
  * @author Jan Hippchen
  * @version 1.6.9.07	
  * @param string $filename Name of the object
  * @param string $path Path to file 
  * @param integer $ref_id ref_id of parent
  */
 function createFile($filename, $path, $ref_id, $tree = null, $access_handler = null)
 {
     global $rbacsystem;
     if (!$access_handler) {
         $permission = $rbacsystem->checkAccess("create", $ref_id, "file");
     } else {
         $permission = $access_handler->checkAccess("create", "", $ref_id, "file");
     }
     if ($permission) {
         // create and insert file in grp_tree
         include_once "./Modules/File/classes/class.ilObjFile.php";
         $fileObj = new ilObjFile();
         $fileObj->setType($this->type);
         $fileObj->setTitle(ilFileUtils::utf8_encode(ilUtil::stripSlashes($filename)));
         $fileObj->setFileName(ilFileUtils::utf8_encode(ilUtil::stripSlashes($filename)));
         // better use this, mime_content_type is deprecated
         include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
         $fileObj->setFileType(ilObjMediaObject::getMimeType($path . "/" . $filename));
         $fileObj->setFileSize(filesize($path . "/" . $filename));
         $fileObj->create();
         // repository
         if (!$access_handler) {
             $fileObj->createReference();
             $fileObj->putInTree($ref_id);
             $fileObj->setPermissions($ref_id);
             self::$new_files[$ref_id][] = $fileObj;
         } else {
             $node_id = $tree->insertObject($ref_id, $fileObj->getId());
             $access_handler->setPermissions($ref_id, $node_id);
         }
         // upload file to filesystem
         $fileObj->createDirectory();
         $fileObj->storeUnzipedFile($path . "/" . $filename, ilFileUtils::utf8_encode(ilUtil::stripSlashes($filename)));
     } else {
         $this->ilErr->raiseError($this->lng->txt("permission_denied"), $this->ilErr->MESSAGE);
     }
 }
开发者ID:arlendotcn,项目名称:ilias,代码行数:46,代码来源:class.ilFileUtils.php

示例9: configureFile

 /**
  * Configures the file for the updateFloorPlanInfosWithFile and addFloorPlan function.
  *
  * @param ilObjMediaObject $a_mediaObj
  * @param array            $a_newfile
  *
  * @return array with format and filename
  */
 private function configureFile($a_mediaObj, $a_newfile = NULL)
 {
     if ($this->mobjMock) {
         return $a_newfile;
     }
     $mob_dir = ilObjMediaObject::_getDirectory($a_mediaObj->getId());
     if (!is_dir($mob_dir)) {
         $a_mediaObj->createDirectory();
     }
     $file_name = ilUtil::getASCIIFilename($a_newfile["name"]);
     $file_name_mod = str_replace(" ", "_", $file_name);
     $file = $mob_dir . "/" . $file_name_mod;
     // construct file path
     ilUtil::moveUploadedFile($a_newfile["tmp_name"], $file_name_mod, $file);
     ilUtil::renameExecutables($mob_dir);
     $format = ilObjMediaObject::getMimeType($file);
     return array("format" => $format, "filename" => $file_name_mod);
 }
开发者ID:studer-raimann,项目名称:RoomSharing,代码行数:26,代码来源:class.ilRoomSharingFloorPlans.php

示例10: update

 /**
  * Update (base image)
  */
 function update()
 {
     global $ilCtrl, $lng;
     $mob = $this->content_obj->getMediaObject();
     $mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
     $std_item = $mob->getMediaItem("Standard");
     $location = $_FILES['image_file']['name'];
     if ($location != "" && is_file($_FILES['image_file']['tmp_name'])) {
         $file = $mob_dir . "/" . $_FILES['image_file']['name'];
         ilUtil::moveUploadedFile($_FILES['image_file']['tmp_name'], $_FILES['image_file']['name'], $file);
         // get mime type
         $format = ilObjMediaObject::getMimeType($file);
         $location = $_FILES['image_file']['name'];
         $std_item->setFormat($format);
         $std_item->setLocation($location);
         $std_item->setLocationType("LocalFile");
         $mob->setDescription($format);
         $mob->update();
     }
     // set caption
     $std_alias_item = new ilMediaAliasItem($this->dom, $this->getHierId(), "Standard", $this->content_obj->getPcId(), "InteractiveImage");
     $std_alias_item->setCaption(ilUtil::stripSlashes($_POST["caption"]));
     $_SESSION["il_pg_error"] = $this->pg_obj->update();
     ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
     $ilCtrl->redirectByClass("ilpcinteractiveimagegui", "editBaseImage");
 }
开发者ID:arlendotcn,项目名称:ilias,代码行数:29,代码来源:class.ilPCInteractiveImageGUI.php

示例11: dbImportSco


//.........这里部分代码省略.........
                             include_once "./Services/MediaObjects/classes/class.ilMapArea.php";
                             $ma = new ilMapArea();
                             $map_area = new ilMapArea();
                             $map_area->setShape($v[Shape]);
                             $map_area->setCoords($v[Coords]);
                             $map_area->setLinkType(IL_EXT_LINK);
                             $map_area->setTitle($v->ExtLink);
                             $map_area->setHref($v->ExtLink[Href]);
                             $media_item->addMapArea($map_area);
                         }
                     }
                     if ($media_item->getLocationType() == "LocalFile") {
                         //							$tmp_name = $this->packageFolder."/objects/".$OriginId."/".$xMediaItem->Location;
                         //							copy($tmp_name,  $mob_dir."/".$xMediaItem->Location);
                     }
                 }
                 // copy whole directory
                 ilUtil::rCopy($this->packageFolder . "/objects/" . $OriginId, $mob_dir);
                 // alex: fixed media import: these lines have been
                 // behind the next curly bracket which makes it fail
                 // when no medianode is given. (id=0 -> fatal error)
                 ilUtil::renameExecutables($mob_dir);
                 $media_object->update(true);
                 $ttnode[OriginId] = "il__mob_" . $media_object->getId();
             }
         }
         include_once "./Modules/File/classes/class.ilObjFile.php";
         include_once "./Services/Utilities/classes/class.ilFileUtils.php";
         include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
         $intlinks = $page_xml->xpath("//IntLink");
         foreach ($intlinks as $intlink) {
             if ($intlink[Type] != "File") {
                 continue;
             }
             $path = $this->packageFolder . "/objects/" . str_replace('dfile', 'file', $intlink[Target]);
             if (!is_dir($path)) {
                 continue;
             }
             $ffiles = array();
             ilFileUtils::recursive_dirscan($path, $ffiles);
             $filename = $ffiles[file][0];
             $fileObj = new ilObjFile();
             $fileObj->setType("file");
             $fileObj->setTitle(ilFileUtils::utf8_encode(ilUtil::stripSlashes($filename)));
             $fileObj->setFileName(ilFileUtils::utf8_encode(ilUtil::stripSlashes($filename)));
             // better use this, mime_content_type is deprecated
             $fileObj->setFileType(ilObjMediaObject::getMimeType($path . "/" . $filename));
             $fileObj->setFileSize(filesize($path . "/" . $filename));
             $fileObj->create();
             $fileObj->createReference();
             //$fileObj->putInTree($_GET["ref_id"]);
             //$fileObj->setPermissions($slm->getId ());
             $fileObj->createDirectory();
             $fileObj->storeUnzipedFile($path . "/" . $filename, ilFileUtils::utf8_encode(ilUtil::stripSlashes($filename)));
             $intlink[Target] = "il__dfile_" . $fileObj->getId();
         }
         $fileitems = $page_xml->xpath("//FileItem/Identifier");
         foreach ($fileitems as $fileitem) {
             $path = $this->packageFolder . "/objects/" . $fileitem[Entry];
             if (!is_dir($path)) {
                 continue;
             }
             $ffiles = array();
             ilFileUtils::recursive_dirscan($path, $ffiles);
             $filename = $ffiles[file][0];
             $fileObj = new ilObjFile();
             $fileObj->setType("file");
             $fileObj->setTitle(ilFileUtils::utf8_encode(ilUtil::stripSlashes($filename)));
             $fileObj->setFileName(ilFileUtils::utf8_encode(ilUtil::stripSlashes($filename)));
             // better use this, mime_content_type is deprecated
             $fileObj->setFileType(ilObjMediaObject::getMimeType($path . "/" . $filename));
             $fileObj->setFileSize(filesize($path . "/" . $filename));
             $fileObj->create();
             $fileObj->createReference();
             //$fileObj->putInTree($_GET["ref_id"]);
             //$fileObj->setPermissions($slm->getId ());
             $fileObj->createDirectory();
             $fileObj->storeUnzipedFile($path . "/" . $filename, ilFileUtils::utf8_encode(ilUtil::stripSlashes($filename)));
             $fileitem[Entry] = "il__file_" . $fileObj->getId();
         }
         $pagex = new ilSCORM2004Page($page->getId());
         $ddoc = new DOMDocument();
         $ddoc->async = false;
         $ddoc->preserveWhiteSpace = false;
         $ddoc->formatOutput = false;
         $ddoc->loadXML($page_xml->asXML());
         $xpath = new DOMXPath($ddoc);
         $tnode = $xpath->query('PageContent');
         $t = "<PageObject>";
         foreach ($tnode as $ttnode) {
             $t .= $ddoc->saveXML($ttnode);
         }
         $t .= "</PageObject>";
         foreach ($qtis as $old => $q) {
             $t = str_replace($old, 'il__qst_' . $q['pool'], $t);
         }
         $pagex->setXMLContent($t);
         $pagex->updateFromXML();
     }
 }
开发者ID:khanhnnvn,项目名称:ilias_E-learning,代码行数:101,代码来源:ilSCORM13Package.php

示例12: getMp3PlayerHtml

 /**
  * Get Html for MP3 Player
  */
 function getMp3PlayerHtml($a_preview = false)
 {
     global $tpl, $lng;
     include_once "./Services/YUI/classes/class.ilYuiUtil.php";
     ilYuiUtil::initConnection();
     $tpl->addJavascript("./Services/MediaObjects/js/MediaObjects.js");
     if (!self::$lightbox_initialized && $a_preview) {
         include_once "./Services/UIComponent/Lightbox/classes/class.ilLightboxGUI.php";
         $lb = new ilLightboxGUI("media_lightbox");
         $lb->setWidth("660px");
         $lb->addLightbox();
         self::$lightbox_initialized = true;
     }
     require_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
     include_once "./Services/MediaObjects/classes/class.ilExternalMediaAnalyzer.php";
     // youtube
     /*		if (ilExternalMediaAnalyzer::isYouTube($this->getFile()))
     		{
     			$p = ilExternalMediaAnalyzer::extractYouTubeParameters($this->getFile());
     			$html = '<object width="320" height="240">'.
     				'<param name="movie" value="http://www.youtube.com/v/'.$p["v"].'?fs=1">'.
     				'</param><param name="allowFullScreen" value="true"></param>'.
     				'<param name="allowscriptaccess" value="always">'.
     				'</param><embed src="http://www.youtube.com/v/'.$p["v"].'?fs=1" '.
     				'type="application/x-shockwave-flash" allowscriptaccess="always" '.
     				'allowfullscreen="true" width="320" height="240"></embed></object>';
     			return $html;
     		}
     
     		// vimeo
     		if (ilExternalMediaAnalyzer::isVimeo($this->getFile()))
     		{
     			$p = ilExternalMediaAnalyzer::extractVimeoParameters($this->getFile());
     
     			$html = '<iframe src="http://player.vimeo.com/video/'.$p["id"].'" width="320" height="240" '.
     				'frameborder="0"></iframe>';
     
     			return $html;
     		}
     */
     $mimeType = $this->mimeType == "" ? ilObjMediaObject::getMimeType(basename($this->getFile())) : $this->mimeType;
     include_once "./Services/MediaObjects/classes/class.ilPlayerUtil.php";
     // video tag
     if (in_array($mimeType, array("video/mp4", "video/m4v", "video/rtmp", "video/x-flv", "video/webm", "video/youtube", "video/vimeo", "video/ogg"))) {
         ilPlayerUtil::initMediaElementJs();
         if ($mimeType == "video/quicktime") {
             $mimeType = "video/mov";
         }
         $mp_tpl = new ilTemplate("tpl.flv_player.html", true, true, "Services/MediaObjects");
         // preview
         if ($a_preview) {
             if ($this->getDownloadLink() != "") {
                 $mp_tpl->setCurrentBlock("download");
                 $mp_tpl->setVariable("TXT_DOWNLOAD", $lng->txt("download"));
                 $mp_tpl->setVariable("HREF_DOWNLOAD", $this->getDownloadLink());
                 $mp_tpl->parseCurrentBlock();
             }
             $mp_tpl->setCurrentBlock("preview");
             if ($this->getVideoPreviewPic() != "") {
                 $mp_tpl->setVariable("IMG_SRC", $this->getVideoPreviewPic());
             } else {
                 $mp_tpl->setVariable("IMG_SRC", ilUtil::getImagePath("mcst_preview.svg"));
             }
             $mp_tpl->setVariable("IMG_ALT", $this->video_preview_pic_alt);
             $mp_tpl->setVariable("PTITLE", $this->getTitle());
             $mp_tpl->parseCurrentBlock();
         }
         // sources
         $mp_tpl->setCurrentBlock("source");
         $mp_tpl->setVariable("FILE", $this->getFile());
         $mp_tpl->setVariable("MIME", $mimeType);
         $mp_tpl->parseCurrentBlock();
         if (in_array($this->getAlternativeVideoMimeType(), array("video/mp4", "video/webm"))) {
             $mp_tpl->setCurrentBlock("source");
             $mp_tpl->setVariable("FILE", $this->getAlternativeVideoFile());
             $mp_tpl->setVariable("MIME", $this->getAlternativeVideoMimeType());
             $mp_tpl->parseCurrentBlock();
         }
         $mp_tpl->setCurrentBlock("mejs_video");
         if ($a_preview) {
             $mp_tpl->setVariable("CLASS", "ilNoDisplay");
         }
         $mp_tpl->setVariable("PLAYER_NR", $this->id . "_" . $this->current_nr);
         $mp_tpl->setVariable("EVENT_URL", $this->event_callback_url);
         $height = $this->getDisplayHeight();
         $width = $this->getDisplayWidth();
         if (is_int(strpos($mimeType, "audio/mpeg"))) {
             $height = "30";
         }
         $mp_tpl->setVariable("DISPLAY_HEIGHT", $height);
         $mp_tpl->setVariable("DISPLAY_WIDTH", $width);
         $mp_tpl->setVariable("PREVIEW_PIC", $this->getVideoPreviewPic());
         $mp_tpl->setVariable("SWF_FILE", ilPlayerUtil::getFlashVideoPlayerFilename(true));
         $mp_tpl->setVariable("FFILE", $this->getFile());
         $mp_tpl->setVariable("TITLE", $this->getTitle());
         $mp_tpl->setVariable("DESCRIPTION", $this->getDescription());
         include_once "./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php";
//.........这里部分代码省略.........
开发者ID:arlendotcn,项目名称:ilias,代码行数:101,代码来源:class.ilMediaPlayerGUI.php

示例13: assignFullscreenObject

 /**
  * assign file to fullscreen view
  */
 function assignFullscreenObject()
 {
     if (!isset($_POST["file"])) {
         $this->ilias->raiseError($this->lng->txt("no_checkbox"), $this->ilias->error_obj->MESSAGE);
     }
     if (count($_POST["file"]) > 1) {
         $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"), $this->ilias->error_obj->MESSAGE);
     }
     // determine directory
     $cur_subdir = str_replace(".", "", $_GET["cdir"]);
     $mob_dir = ilUtil::getWebspaceDir() . "/mobs/mm_" . $this->object->getId();
     $cur_dir = !empty($cur_subdir) ? $mob_dir . "/" . $cur_subdir : $mob_dir;
     $file = $cur_dir . "/" . $_POST["file"][0];
     $location = !empty($cur_subdir) ? $cur_subdir . "/" . $_POST["file"][0] : $_POST["file"][0];
     if (!is_file($file)) {
         $this->ilias->raiseError($this->lng->txt("cont_select_file"), $this->ilias->error_obj->MESSAGE);
     }
     if (!$this->object->hasFullScreenItem()) {
         // create new fullscreen item
         $std_item =& $this->object->getMediaItem("Standard");
         $mob_dir = ilUtil::getWebspaceDir() . "/mobs/mm_" . $this->object->getId();
         $file = $mob_dir . "/" . $location;
         $full_item =& new ilMediaItem();
         $full_item->setMobId($std_item->getMobId());
         $full_item->setLocation($location);
         $full_item->setLocationType("LocalFile");
         $full_item->setFormat(ilObjMediaObject::getMimeType($file));
         $full_item->setPurpose("Fullscreen");
         $this->object->addMediaItem($full_item);
     } else {
         $full_item =& $this->object->getMediaItem("Fullscreen");
         $full_item->setLocationType("LocalFile");
         $full_item->setLocation($location);
         $format = ilObjMediaObject::getMimeType($file);
         $full_item->setFormat($format);
     }
     $this->object->update();
     //		$this->ctrl->saveParameter($this, "cdir");
     $this->ctrl->redirectByClass("ilfilesystemgui", "listFiles");
 }
开发者ID:arlendotcn,项目名称:ilias,代码行数:43,代码来源:class.ilObjMediaObjectGUI.php

示例14: checkValidity

 public function checkValidity($value, $record_id = null)
 {
     //Don't check empty values
     if ($value == NULL) {
         return true;
     }
     if (!ilDataCollectionDatatype::checkValidity($this->getDatatypeId(), $value)) {
         throw new ilDataCollectionInputException(ilDataCollectionInputException::TYPE_EXCEPTION);
     }
     $properties = $this->getPropertyvalues();
     $length = ilDataCollectionField::PROPERTYID_LENGTH;
     $regex_id = ilDataCollectionField::PROPERTYID_REGEX;
     $url = ilDataCollectionField::PROPERTYID_URL;
     if ($this->getDatatypeId() == ilDataCollectionDatatype::INPUTFORMAT_TEXT) {
         $regex = $properties[$regex_id];
         if (substr($regex, 0, 1) != "/") {
             $regex = "/" . $regex;
         }
         if (substr($regex, -1) != "/") {
             $regex .= "/";
         }
         if ($properties[$length] < strlen($value) && is_numeric($properties[$length])) {
             throw new ilDataCollectionInputException(ilDataCollectionInputException::LENGTH_EXCEPTION);
         }
         if (!($properties[$regex_id] == NULL || @preg_match($regex, $value))) {
             throw new ilDataCollectionInputException(ilDataCollectionInputException::REGEX_EXCEPTION);
         }
         //email or url
         if ($properties[$url] && !(preg_match('~(^(news|(ht|f)tp(s?)\\://){1}\\S+)~i', $value) || preg_match("/^[a-z0-9!#\$%&'*+=?^_`{|}~-]+(?:\\.[a-z0-9!#\$%&'*+=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\$/i", $value))) {
             throw new ilDataCollectionInputException(ilDataCollectionInputException::NOT_URL);
         }
     }
     if ($this->getDatatypeId() == ilDataCollectionDatatype::INPUTFORMAT_MOB and $value['name']) {
         $arrMimeType = explode('/', ilObjMediaObject::getMimeType($value['name']));
         if ($arrMimeType[0] != "image") {
             throw new ilDataCollectionInputException(ilDataCollectionInputException::NOT_IMAGE);
         }
     }
     if ($this->isUnique() && $record_id === null) {
         $table = ilDataCollectionCache::getTableCache($this->getTableId());
         foreach ($table->getRecords() as $record) {
             if ($record->getRecordFieldValue($this->getId()) == $value && ($record->getId() != $record_id || $record_id == 0)) {
                 throw new ilDataCollectionInputException(ilDataCollectionInputException::UNIQUE_EXCEPTION);
             }
             //for text it has to be case insensitive.
             if ($this->getDatatypeId() == ilDataCollectionDatatype::INPUTFORMAT_TEXT) {
                 if (strtolower($record->getRecordFieldValue($this->getId())) == strtolower($value) && ($record->getId() != $record_id || $record_id == 0)) {
                     throw new ilDataCollectionInputException(ilDataCollectionInputException::UNIQUE_EXCEPTION);
                 }
             }
             if ($this->getDatatypeId() == ilDataCollectionDatatype::INPUTFORMAT_DATETIME) {
                 $datestring = $value["date"] . " " . $value["time"];
                 //["y"]."-".$value["date"]['m']."-".$value["date"]['d']." 00:00:00";
                 if ($record->getRecordFieldValue($this->getId()) == $datestring && ($record->getId() != $record_id || $record_id == 0)) {
                     throw new ilDataCollectionInputException(ilDataCollectionInputException::UNIQUE_EXCEPTION);
                 }
             }
         }
     }
     return true;
 }
开发者ID:khanhnnvn,项目名称:ilias_E-learning,代码行数:61,代码来源:class.ilDataCollectionField.php

示例15: parseValue

 /**
  * Function to parse incoming data from form input value $value. returns the strin/number/etc. to store in the database.
  * @param $value
  * @param ilDataCollectionRecordField $record_field
  * @return int|string
  */
 public function parseValue($value, ilDataCollectionRecordField $record_field)
 {
     $return = false;
     if ($this->id == ilDataCollectionDatatype::INPUTFORMAT_FILE) {
         $file = $value;
         if ($file['tmp_name']) {
             $file_obj = new ilObjFile();
             $file_obj->setType("file");
             $file_obj->setTitle($file["name"]);
             $file_obj->setFileName($file["name"]);
             $file_obj->setFileType(ilMimeTypeUtil::getMimeType("", $file["name"], $file["type"]));
             $file_obj->setFileSize($file["size"]);
             $file_obj->setMode("object");
             $file_obj->create();
             $file_obj->getUploadFile($file["tmp_name"], $file["name"]);
             $file_id = $file_obj->getId();
             $return = $file_id;
         } else {
             $return = $record_field->getValue();
         }
     } elseif ($this->id == ilDataCollectionDatatype::INPUTFORMAT_MOB) {
         if ($value == -1) {
             //marked for deletion.
             return 0;
         }
         $media = $value;
         if ($media['tmp_name']) {
             $mob = new ilObjMediaObject();
             $mob->setTitle($media['name']);
             $mob->create();
             $mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
             if (!is_dir($mob_dir)) {
                 $mob->createDirectory();
             }
             $media_item = new ilMediaItem();
             $mob->addMediaItem($media_item);
             $media_item->setPurpose("Standard");
             $file_name = ilUtil::getASCIIFilename($media['name']);
             $file_name = str_replace(" ", "_", $file_name);
             $file = $mob_dir . "/" . $file_name;
             $title = $file_name;
             ilUtil::moveUploadedFile($media['tmp_name'], $file_name, $file);
             ilUtil::renameExecutables($mob_dir);
             list($width, $height, $type, $attr) = getimagesize($file);
             $arr_properties = $record_field->getField()->getProperties();
             $new_width = $arr_properties[ilDataCollectionField::PROPERTYID_WIDTH];
             $new_height = $arr_properties[ilDataCollectionField::PROPERTYID_HEIGHT];
             if ($new_width || $new_height) {
                 //only resize if it is bigger, not if it is smaller
                 if ($new_height < $height && $new_width < $width) {
                     //resize proportional
                     if (!$new_height || !$new_width) {
                         $format = ilObjMediaObject::getMimeType($file);
                         $wh = ilObjMediaObject::_determineWidthHeight("", "", $format, "File", $file, "", true, false, $arr_properties[ilDataCollectionField::PROPERTYID_WIDTH], (int) $arr_properties[ilDataCollectionField::PROPERTYID_HEIGHT]);
                     } else {
                         $wh['width'] = (int) $arr_properties[ilDataCollectionField::PROPERTYID_WIDTH];
                         $wh['height'] = (int) $arr_properties[ilDataCollectionField::PROPERTYID_HEIGHT];
                     }
                 }
                 $location = ilObjMediaObject::_resizeImage($file, $wh['width'], $wh['height'], false);
             } else {
                 $location = $title;
             }
             ilObjMediaObject::_saveUsage($mob->getId(), "dcl:html", $record_field->getRecord()->getTable()->getCollectionObject()->getId());
             $format = ilObjMediaObject::getMimeType($file);
             $media_item->setFormat($format);
             $media_item->setLocation($location);
             $media_item->setLocationType("LocalFile");
             $mob->update();
             $return = $mob->getId();
         } else {
             $return = $record_field->getValue();
         }
     } elseif ($this->id == ilDataCollectionDatatype::INPUTFORMAT_DATETIME) {
         return $value["date"] . " " . $value["time"];
     } elseif ($this->id == ilDataCollectionDatatype::INPUTFORMAT_BOOLEAN) {
         $return = $value ? 1 : 0;
     } elseif ($this->id == ilDataCollectionDatatype::INPUTFORMAT_TEXT) {
         $arr_properties = $record_field->getField()->getProperties();
         if ($arr_properties[ilDataCollectionField::PROPERTYID_TEXTAREA]) {
             $return = nl2br($value);
         } else {
             $return = $value;
         }
     } else {
         if ($this->id == ilDataCollectionDatatype::INPUTFORMAT_NUMBER) {
             $return = $value == '' ? null : $value;
             //SW, Ilias Mantis #0011799: Return null otherwise '' is casted to 0 in DB
         } else {
             $return = $value;
         }
     }
     return $return;
 }
开发者ID:Walid-Synakene,项目名称:ilias,代码行数:100,代码来源:class.ilDataCollectionDatatype.php


注:本文中的ilObjMediaObject::getMimeType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。