comparison msite.inc.php @ 781:6e9e42005701

Cleanups, fixes.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 20 Nov 2014 16:35:30 +0200
parents f8d09e0de027
children 7735f97b2bbf
comparison
equal deleted inserted replaced
780:f8d09e0de027 781:6e9e42005701
693 $entryPath = stGetSetting("entryPath"); 693 $entryPath = stGetSetting("entryPath");
694 $previewPath = stGetSetting("previewPath"); 694 $previewPath = stGetSetting("previewPath");
695 $previewURL = stGetSetting("previewURL"); 695 $previewURL = stGetSetting("previewURL");
696 $thumbDir = stGetSetting("thumbnailSubDir"); 696 $thumbDir = stGetSetting("thumbnailSubDir");
697 697
698 $filename = $entry["filename"];
699
698 // Data for the actual entry file 700 // Data for the actual entry file
699 $res["previewType"] = ($entry["preview_type"] != EPREV_NONE) ? $entry["preview_type"] : $compo["preview_type"]; 701 $res["previewType"] = ($entry["preview_type"] != EPREV_NONE) ? $entry["preview_type"] : $compo["preview_type"];
700 $res["entryFile"] = stMakePath(FALSE, FALSE, array($entryPath, $compo["cpath"], $entry["filename"])); 702 $res["entryFile"] = stMakePath(FALSE, FALSE, array($entryPath, $compo["cpath"], $filename));
701 if ($fullData) 703 if ($fullData)
702 { 704 {
703 $res["entrySize"] = @filesize($res["entryFile"]); 705 $res["entrySize"] = @filesize($res["entryFile"]);
704 } 706 }
705 707
706 // Based on preview type, set some basics 708 // Based on preview type, set some basics
707 switch ($res["previewType"]) 709 switch ($res["previewType"])
708 { 710 {
709 case EPREV_IMAGE: 711 case EPREV_IMAGE:
710 $res["fileBase"] = stMakePath(FALSE, "_sshot", array($entry["filename"])); 712 $res["fileBase"] = stMakePath(FALSE, "_sshot", array($filename));
711 $res["preferType"] = "PNG"; 713 $res["preferType"] = "PNG";
712 $fileTypeList = array( 714 $fileTypeList = array(
713 "PNG" => array(".png", ".PNG"), 715 "PNG" => array(".png", ".PNG"),
714 "GIF" => array(".gif", ".GIF"), 716 "GIF" => array(".gif", ".GIF"),
715 "JPEG" => array(".jpg", ".JPG"), 717 "JPEG" => array(".jpg", ".JPG"),
716 ); 718 );
717 break; 719 break;
718 720
719 case EPREV_AUDIO: 721 case EPREV_AUDIO:
720 $res["fileBase"] = stMakePath(FALSE, "_sample", array($entry["filename"])); 722 $res["fileBase"] = stMakePath(FALSE, "_sample", array($filename));
721 $res["preferType"] = "PNG"; 723 $res["preferType"] = "PNG";
722 $fileTypeList = array( 724 $fileTypeList = array(
723 "MP3" => array(".mp3", ".MP3"), 725 "MP3" => array(".mp3", ".MP3"),
724 "OGG" => array(".ogg", ".OGG", ".oga", ".OGA"), 726 "OGG" => array(".ogg", ".OGG", ".oga", ".OGA"),
725 ); 727 );
728 default: 730 default:
729 return FALSE; 731 return FALSE;
730 } 732 }
731 733
732 // Find the preview file(s) 734 // Find the preview file(s)
733 foreach ($fileTypeList as $ftype => $fexts) 735 foreach ($fileTypeList as $fileType => $fileExts)
734 { 736 {
735 foreach ($fexts as $fext) 737 foreach ($fileExts as $fext)
736 { 738 {
737 $filename = stMakePath(FALSE, $fext, array($previewPath, $compo["cpath"], $res["fileBase"])); 739 $filename = stMakePath(FALSE, $fext, array($previewPath, $compo["cpath"], $res["fileBase"]));
738 if ($probePreview == FALSE || file_exists($filename)) 740 if ($probePreview == FALSE || file_exists($filename))
739 { 741 {
740 $res["previewFileType"] = $ftype; 742 $res["previewFileType"] = $fileType;
741 $res["previewPath"] = $filename; 743 $res["previewPath"] = $filename;
742 $res["previewURL"] = stMakePath(TRUE, $fext, array($previewURL, $compo["cpath"], $res["fileBase"])); 744 $res["previewURL"] = stMakePath(TRUE, $fext, array($previewURL, $compo["cpath"], $res["fileBase"]));
743 745
744 if ($res["previewType"] == EPREV_IMAGE) 746 if ($res["previewType"] == EPREV_IMAGE)
745 { 747 {
746 $res["thumbPath"] = stMakePath(TRUE, $fext, array($previewPath, $compo["cpath"], $thumbDir, $res["fileBase"])); 748 $res["thumbPath"] = stMakePath(FALSE, $fext, array($previewPath, $compo["cpath"], $thumbDir, $res["fileBase"]));
747 $res["thumbURL"] = stMakePath(TRUE, $fext, array($previewURL, $compo["cpath"], $thumbDir, $res["fileBase"])); 749 $res["thumbURL"] = stMakePath(TRUE, $fext, array($previewURL, $compo["cpath"], $thumbDir, $res["fileBase"]));
748 } 750 }
749 751
750 if ($fullData) 752 if ($fullData)
751 { 753 {