/**
  * Получение информации о файле
  */
 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);
 }
예제 #2
0
 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 "";
 }
 /**
  * Получение информации о файле
  */
 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);
 }
예제 #4
0
 /**
  * Предпросмотр вложений со ссылками на оригиналы
  *
  * @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 
     }
 }