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


PHP ilObjFile::setMode方法代码示例

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


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

示例1: newFileItem

 /**
  * insert new file item
  */
 function newFileItem()
 {
     global $lng;
     if ($_FILES["file"]["name"] == "") {
         $_GET["subCmd"] = "-";
         ilUtil::sendFailure($lng->txt("upload_error_file_not_found"));
         return false;
     }
     include_once "./Modules/File/classes/class.ilObjFile.php";
     $fileObj = new ilObjFile();
     $fileObj->setType("file");
     $fileObj->setTitle($_FILES["file"]["name"]);
     $fileObj->setDescription("");
     $fileObj->setFileName($_FILES["file"]["name"]);
     $fileObj->setFileType($_FILES["file"]["type"]);
     $fileObj->setFileSize($_FILES["file"]["size"]);
     $fileObj->setMode("filelist");
     $fileObj->create();
     $fileObj->raiseUploadError(false);
     // upload file to filesystem
     $fileObj->createDirectory();
     $fileObj->getUploadFile($_FILES["file"]["tmp_name"], $_FILES["file"]["name"]);
     $this->file_object =& $fileObj;
     return true;
 }
开发者ID:arlendotcn,项目名称:ilias,代码行数:28,代码来源:class.ilPCFileItemGUI.php

示例2: saveFileLink

 /**
  * Save file link
  */
 function saveFileLink()
 {
     $mtpl =& new ilTemplate("tpl.link_help.html", true, true, "Modules/LearningModule");
     $mtpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
     if ($_FILES["link_file"]["name"] != "") {
         include_once "./Modules/File/classes/class.ilObjFile.php";
         $fileObj = new ilObjFile();
         $fileObj->setType("file");
         $fileObj->setTitle($_FILES["link_file"]["name"]);
         $fileObj->setDescription("");
         $fileObj->setFileName($_FILES["link_file"]["name"]);
         $fileObj->setFileType($_FILES["link_file"]["type"]);
         $fileObj->setFileSize($_FILES["link_file"]["size"]);
         $fileObj->setMode("filelist");
         $fileObj->create();
         // upload file to filesystem
         $fileObj->createDirectory();
         $fileObj->raiseUploadError(false);
         $fileObj->getUploadFile($_FILES["link_file"]["tmp_name"], $_FILES["link_file"]["name"]);
         $this->uploaded_file = $fileObj;
     }
     $this->showLinkHelp();
 }
开发者ID:Walid-Synakene,项目名称:ilias,代码行数:26,代码来源:class.ilInternalLinkGUI.php

示例3: 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


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