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


PHP CUtils::getMimetype方法代码示例

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


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

示例1: actionGetInfo

 /**
  * Получение информации о файле
  */
 public function actionGetInfo()
 {
     $storage = $_POST["_storage"];
     $file = $_POST["_file"];
     $size = $_POST["_size"];
     $index = $_POST["_index"];
     $result = array("isImage" => false, "previewUrl" => "", "fullUrl" => "", "url" => "", "name" => $file, "index" => $index);
     if (file_exists($storage . $file)) {
         // заменяем обратный слэш в адресе на прямой
         $linkWithBackSlash = CUtils::strRight($storage, CORE_CWD) . $file;
         $link = str_replace('\\', '/', $linkWithBackSlash);
         $result["fullUrl"] = WEB_ROOT . $link;
         $result["url"] = $link;
         $result["isImage"] = CUtils::isImage($storage . $file);
         if (CUtils::isImage($storage . $file)) {
             $result["previewUrl"] = WEB_ROOT . "_modules/_thumbnails/?src=" . $result["url"] . "&w=" . $size;
         } else {
             $filetype = CUtils::getMimetype($storage . $file);
             if (file_exists(CORE_CWD . CORE_DS . "images" . CORE_DS . ICON_THEME . CORE_DS . "64x64" . CORE_DS . "mimetypes" . CORE_DS . $filetype . ".png")) {
                 $result["previewUrl"] = WEB_ROOT . "images/" . ICON_THEME . "/64x64/mimetypes/" . $filetype . ".png";
             } else {
                 $result["previewUrl"] = WEB_ROOT . "images/" . ICON_THEME . "/64x64/mimetypes/unknown.png";
             }
         }
     }
     echo json_encode($result);
 }
开发者ID:Rustam44,项目名称:ASUPortalPHP,代码行数:30,代码来源:CUploadController.class.php

示例2: getIconLink

 public function getIconLink()
 {
     if ($this->isFileExists()) {
         $filetype = CUtils::getMimetype(CORE_CWD . CORE_DS . 'library' . CORE_DS . 'gost' . CORE_DS . $this->nameFile);
         if (file_exists(CORE_CWD . CORE_DS . "images" . CORE_DS . ICON_THEME . CORE_DS . "64x64" . CORE_DS . "mimetypes" . CORE_DS . $filetype . ".png")) {
             return WEB_ROOT . "images/" . ICON_THEME . "/64x64/mimetypes/" . $filetype . ".png";
         } else {
             return WEB_ROOT . "images/" . ICON_THEME . "/64x64/mimetypes/text-x-install.png";
         }
     }
     return "";
 }
开发者ID:Rustam44,项目名称:ASUPortalPHP,代码行数:12,代码来源:CDocumentFile.class.php

示例3: actionGetInfo

 /**
  * Получение информации о файле
  */
 public function actionGetInfo()
 {
     $storage = $_POST["_storage"];
     $file = $_POST["_file"];
     $size = $_POST["_size"];
     $index = $_POST["_index"];
     $result = array("isImage" => false, "previewUrl" => "", "fullUrl" => "", "name" => $file, "index" => $index);
     if (file_exists($storage . $file)) {
         $result["fullUrl"] = WEB_ROOT . CUtils::strRight($storage, CORE_CWD) . $file;
         $result["isImage"] = CUtils::isImage($storage . $file);
         if (CUtils::isImage($storage . $file)) {
             $result["previewUrl"] = WEB_ROOT . "_modules/_thumbnails/?src=" . $result["fullUrl"] . "&w=" . $size;
         } else {
             $filetype = CUtils::getMimetype($storage . $file);
             if (file_exists(CORE_CWD . CORE_DS . "images" . CORE_DS . ICON_THEME . CORE_DS . "64x64" . CORE_DS . "mimetypes" . CORE_DS . $filetype . ".png")) {
                 $result["previewUrl"] = WEB_ROOT . "images/" . ICON_THEME . "/64x64/mimetypes/" . $filetype . ".png";
             } else {
                 $result["previewUrl"] = WEB_ROOT . "images/" . ICON_THEME . "/64x64/mimetypes/unknown.png";
             }
         }
     }
     echo json_encode($result);
 }
开发者ID:Trozeman,项目名称:ASUPortalPHP,代码行数:26,代码来源:CUploadController.class.php

示例4: activeAttachPreview

 /**
  * Предпросмотр вложений со ссылками на оригиналы
  *
  * @param $name
  * @param CModel $model
  * @param int $size
  * @param bool $addLinkToOriginal
  */
 public static function activeAttachPreview($name, CModel $model, $addLinkToOriginal = false, $size = 100)
 {
     $attributes = $model->fieldsProperty();
     $display = false;
     if (array_key_exists($name, $attributes)) {
         $field = $attributes[$name];
         if ($field["type"] == FIELD_UPLOADABLE) {
             $storage = $field["upload_dir"];
             $file = $model->{$name};
             if ($file !== "") {
                 if (file_exists($storage . $file)) {
                     $display = true;
                 }
             }
         }
     }
     if ($display) {
         // заменяем обратный слэш в адресе на прямой
         $linkWithBackSlash = CUtils::strRight($storage, CORE_CWD) . $file;
         $link = str_replace('\\', '/', $linkWithBackSlash);
         $icon = "";
         if (CUtils::isImage($storage . $file)) {
             // показываем превью изображения
             $icon = WEB_ROOT . "_modules/_thumbnails/?src=" . $link . "&w=" . $size;
         } else {
             // показываем значок типа документа
             $filetype = CUtils::getMimetype($storage . $file);
             if (file_exists(CORE_CWD . CORE_DS . "images" . CORE_DS . ICON_THEME . CORE_DS . "64x64" . CORE_DS . "mimetypes" . CORE_DS . $filetype . ".png")) {
                 $icon = WEB_ROOT . "images/" . ICON_THEME . "/64x64/mimetypes/" . $filetype . ".png";
             } else {
                 $icon = WEB_ROOT . "images/" . ICON_THEME . "/64x64/mimetypes/unknown.png";
             }
         }
         if ($addLinkToOriginal) {
             echo '<a href="' . WEB_ROOT . '' . $link . '" target="_blank"';
             if (CUtils::isImage($storage . $file)) {
                 echo ' class="image_clearboxy"';
             }
             echo '>';
         }
         echo '<img src="' . $icon . '" />';
         if ($addLinkToOriginal) {
             echo '</a>';
         }
     }
     if (!self::$_clearboxInit) {
         self::$_clearboxInit = true;
         ?>
         <script>
             jQuery(document).ready(function(){
                 jQuery("a.image_clearboxy").colorbox({
                     maxHeight: "100%",
                     title: function(){
                         var url = $(this).attr('href');
                         return '<a href="' + url + '" target="_blank">Открыть в полном размере</a>';
                     }
                 });
             });
         </script>
         <?php 
     }
 }
开发者ID:Rustam44,项目名称:ASUPortalPHP,代码行数:70,代码来源:CHtml.class.php


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