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


PHP ilObjMediaObject::_resizeImage方法代码示例

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


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

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

示例2: savePropertiesObject

 /**
  * save properties in db and return to page edit screen
  */
 function savePropertiesObject()
 {
     global $lng, $tpl;
     $this->initForm("edit");
     if ($this->form_gui->checkInput()) {
         $title = trim($_POST["standard_title"]);
         $this->object->setTitle($title);
         $std_item = $this->object->getMediaItem("Standard");
         $location = $std_item->getLocation();
         $format = $std_item->getFormat();
         if ($_POST["standard_type"] == "Reference") {
             $format = ilObjMediaObject::getMimeType(ilUtil::stripSlashes($_POST["standard_reference"]));
             $std_item->setFormat($format);
             $std_item->setLocation(ilUtil::secureLink(ilUtil::stripSlashes($_POST["standard_reference"])));
             $std_item->setLocationType("Reference");
         }
         $mob_dir = ilObjMediaObject::_getDirectory($this->object->getId());
         if ($_POST["standard_type"] == "File") {
             $resize = false;
             if ($_FILES['standard_file']['name'] != "") {
                 $file_name = ilObjMediaObject::fixFilename($_FILES['standard_file']['name']);
                 $file = $mob_dir . "/" . $file_name;
                 ilUtil::moveUploadedFile($_FILES['standard_file']['tmp_name'], $file_name, $file);
                 // get mime type
                 $format = ilObjMediaObject::getMimeType($file);
                 $location = $file_name;
                 $resize = true;
             } else {
                 if ($_POST["standard_resize"]) {
                     $file = $mob_dir . "/" . $location;
                     $resize = true;
                 }
             }
             // resize
             if ($resize) {
                 if ($_POST["standard_size"] != "original" && is_int(strpos($format, "image"))) {
                     $location = ilObjMediaObject::_resizeImage($file, (int) $_POST["standard_width_height"]["width"], (int) $_POST["standard_width_height"]["height"], (bool) $_POST["standard_width_height"]["contr_prop"]);
                 }
                 $std_item->setFormat($format);
                 $std_item->setLocation($location);
             }
             $std_item->setLocationType("LocalFile");
         }
         $this->object->setDescription($format);
         // determine width and height of known image types
         $wh = ilObjMediaObject::_determineWidthHeight(500, 400, $format, $_POST["standard_type"], $mob_dir . "/" . $location, $std_item->getLocation(), $_POST["standard_width_height"]["constr_prop"], $_POST["standard_size"] == "original", $_POST["standard_width_height"]["width"], $_POST["standard_width_height"]["height"]);
         if ($wh["info"] != "") {
             ilUtil::sendInfo($wh["info"], true);
         }
         $std_item->setWidth($wh["width"]);
         $std_item->setHeight($wh["height"]);
         // set caption
         $std_item->setCaption(ilUtil::stripSlashes($_POST["standard_caption"]));
         // text representation
         $std_item->setTextRepresentation(ilUtil::stripSlashes($_POST["text_representation"]));
         // set parameters
         if (!in_array($std_item->getFormat(), ilObjMediaObject::_getSimpleMimeTypes())) {
             if (ilObjMediaObject::_useAutoStartParameterOnly($std_item->getLocation(), $std_item->getFormat())) {
                 if ($_POST["standard_autostart"]) {
                     $std_item->setParameters('autostart="true"');
                 } else {
                     $std_item->setParameters("");
                 }
             } else {
                 $std_item->setParameters(ilUtil::stripSlashes(utf8_decode($_POST["standard_parameters"])));
             }
         }
         // "None" selected
         if ($_POST["full_type"] == "None") {
             if ($this->object->hasFullscreenItem()) {
                 $this->object->removeMediaItem("Fullscreen");
             }
         } else {
             if ($this->object->hasFullscreenItem()) {
                 $full_item = $this->object->getMediaItem("Fullscreen");
             } else {
                 $full_item = new ilMediaItem();
                 $this->object->addMediaItem($full_item);
                 $full_item->setPurpose("Fullscreen");
             }
             $location = $full_item->getLocation();
             $format = $full_item->getFormat();
             if ($_POST["full_type"] == "Reference") {
                 $format = ilObjMediaObject::getMimeType(ilUtil::stripSlashes($_POST["full_reference"]));
                 $full_item->setFormat($format);
                 $full_item->setLocationType("Reference");
                 $location = ilUtil::stripSlashes($_POST["full_reference"]);
                 $type = "Reference";
             }
             $mob_dir = ilObjMediaObject::_getDirectory($this->object->getId());
             if ($_POST["full_type"] == "File") {
                 $resize = false;
                 if ($_FILES['full_file']['name'] != "") {
                     $full_file_name = ilObjMediaObject::fixFilename($_FILES['full_file']['name']);
                     $file = $mob_dir . "/" . $full_file_name;
                     ilUtil::moveUploadedFile($_FILES['full_file']['tmp_name'], $full_file_name, $file);
                     $format = ilObjMediaObject::getMimeType($file);
//.........这里部分代码省略.........
开发者ID:arlendotcn,项目名称:ilias,代码行数:101,代码来源:class.ilObjMediaObjectGUI.php


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