Skip to content

Commit

Permalink
v2.11.2 Community Updates
Browse files Browse the repository at this point in the history
Enhancement: Cache Config Options (Issue MattsShack#63)
- Consolidate all CacheClear functions into a single reusable function.
- Add placeholder for Cache config input fields

Enhancement: Full Screen Poster (Issue MattsShack#57)
- Full Screen Poster using 'FullScreenArtMode'.

Updates and Bug Fixes:
- Update Custom Image upload to support only the following file types: zip/jpg/jpeg/gif/png
  • Loading branch information
ZeroCoolGOS committed Mar 25, 2021
1 parent 7d5f43d commit c832299
Show file tree
Hide file tree
Showing 15 changed files with 215 additions and 126 deletions.
2 changes: 1 addition & 1 deletion GitVersion.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ ignore:
sha: []
merge-message-formats: {}
mode: ContinuousDelivery
next-version: 2.11.1
next-version: 2.11.2
124 changes: 37 additions & 87 deletions assets/plexmovieposter/CacheLib.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function GeneralCache_Clear_Placeholder($destination) {
}
}

function GeneralCache_Clear_24H ($destination) {
function GeneralCache_Clear_24H($destination) {
// Clean Up Cache Dir (Files Older than 24 hours)

pmp_Logging("getCacheFile", "24hr Cache Clear: $destination");
Expand All @@ -105,110 +105,60 @@ function GeneralCache_Clear_24H ($destination) {
}
}

function PosterCacheClear($destination = "../cache/posters/") {
//Clear Poster Cache Directory
function GeneralCacheClear($destination = "../cache/posters/", $ScanSubDir = TRUE) {
//Clear Cache Directory

GeneralCache_Create($destination, "PosterCacheClear");

$files = glob("$destination/*");
foreach ($files as $file) {
if (is_file($file)) {
unlink($file);
}
}
}

function CustomCacheClear($destination = "../cache/custom/", $ScanSubDir = TRUE) {
//Clear Custom Cache Directory

GeneralCache_Create($destination, "CustomCacheClear");

if ($ScanSubDir == TRUE) {
// Multi Level
$dir_iterator = new RecursiveDirectoryIterator("$destination");
$iterator = new RecursiveIteratorIterator($dir_iterator, RecursiveIteratorIterator::SELF_FIRST);
// could use CHILD_FIRST if you so wish

foreach ($iterator as $file) {
if (is_file($file)) {
pmp_Logging("getCacheFile", "Removing Custom Image: $file");
unlink($file);
}
}
}
else {
// Single Level
$files = glob("$destination/*");
foreach ($files as $file) {
if (is_file($file)) {
pmp_Logging("getCacheFile", "Removing Custom Image: $file");
unlink($file);
}
}
}

}

function ArtCacheClear($destination = "../cache/art/") {
//Clear Art Cache Directory

GeneralCache_Create($destination, "ArtCacheClear");

$files = glob("$destination/*");
foreach ($files as $file) {
if (is_file($file)) {
unlink($file);
}
}
}

function LogCacheClear($destination = "../cache/logs/") {
//Clear Log Cache Directory
// Condense all Clear Cache into single function.

GeneralCache_Create($destination, "LogCacheClear");

$files = glob("$destination/*");
foreach ($files as $file) {
if (is_file($file)) {
unlink($file);
}
// Global Variables - Input
global $pmpPosterDir, $pmpArtDir, $pmpCustomDir, $pmpFontDir, $pmpLogDir;

switch ($destination) {
case "poster":
$destination = "../$pmpPosterDir";
break;
case "art":
$destination = "../$pmpArtDir";
break;
case "custom":
$destination = "../$pmpCustomDir";
break;
case "font":
$destination = "../$pmpFontDir";
break;
case "log":
$destination = "../$pmpLogDir";
break;
default:
$destination = "../$pmpPosterDir";
break;
}
}

function FontCacheClear($destination = "../cache/fonts/", $ScanSubDir = TRUE) {
//Clear Custom Font Cache Directory
// ToDo: Add support to clean up empty directories

GeneralCache_Create($destination, "FontCacheClear");
GeneralCache_Create($destination, "GeneralCacheClear");

if ($ScanSubDir == TRUE) {
// Multi Level
// Multi Level Search
$dir_iterator = new RecursiveDirectoryIterator("$destination");
$iterator = new RecursiveIteratorIterator($dir_iterator, RecursiveIteratorIterator::SELF_FIRST);
// could use CHILD_FIRST if you so wish

foreach ($iterator as $file) {
if (is_file($file)) {
pmp_Logging("getCacheFile", "Removing Font: $file");
pmp_Logging("getCacheFile", "Removing Image ($destination): $file");
unlink($file);
}
}
}
else {
// Single Level
// Single Level Search
$files = glob("$destination/*");
foreach ($files as $file) {
if (is_file($file)) {
pmp_Logging("getCacheFile", "Removing Font: $file");
pmp_Logging("getCacheFile", "Removing Image ($destination): $file");
unlink($file);
}
}
}
}



function CacheInfo_Display($MiniStatus = FALSE) {
global $posterCount, $customCount, $customFontCount, $logCount, $BGArtCount;

Expand Down Expand Up @@ -309,16 +259,16 @@ function CacheConfig_Display() {

echo "<table class=\"$tblClass\">";

CacheConfig_Display_ROW("Posters:",TRUE,"pmpPosterDir","$pmpPosterDir","pmpPosterDir_24hExp","$pmpPosterDir_24hExp");
CacheConfig_Display_ROW("Background Art:",TRUE,"pmpArtDir","$pmpArtDir","pmpArtDir_24hExp","$pmpArtDir_24hExp");
CacheConfig_Display_ROW("Custom Images:",TRUE,"pmpCustomDir","$pmpCustomDir","pmpCustomDir_24hExp","$pmpCustomDir_24hExp");
CacheConfig_Display_ROW("Custom Fonts:",TRUE,"pmpFontDir","$pmpFontDir","pmpFontDir_24hExp","$pmpFontDir_24hExp");
CacheConfig_Display_ROW("Custom Logs:",TRUE,"pmpLogDir","$pmpLogDir","pmpLogDir_24hExp","$pmpLogDir_24hExp");
CacheConfig_Display_ROW("Posters:",TRUE,"pmpPosterDir","$pmpPosterDir","pmpPosterDir_24hExp","$pmpPosterDir_24hExp","cache/posters/");
CacheConfig_Display_ROW("Background Art:",TRUE,"pmpArtDir","$pmpArtDir","pmpArtDir_24hExp","$pmpArtDir_24hExp","cache/art/");
CacheConfig_Display_ROW("Custom Images:",TRUE,"pmpCustomDir","$pmpCustomDir","pmpCustomDir_24hExp","$pmpCustomDir_24hExp","cache/custom/");
CacheConfig_Display_ROW("Custom Fonts:",TRUE,"pmpFontDir","$pmpFontDir","pmpFontDir_24hExp","$pmpFontDir_24hExp","cache/fonts/");
CacheConfig_Display_ROW("Custom Logs:",TRUE,"pmpLogDir","$pmpLogDir","pmpLogDir_24hExp","$pmpLogDir_24hExp","cache/logs/");

echo "</table>\n";
}

function CacheConfig_Display_ROW($Title, $Help, $InputField, $InputValue, $InputFieldExp, $InputValueExp){
function CacheConfig_Display_ROW($Title, $Help, $InputField, $InputValue, $InputFieldExp, $InputValueExp,$InputPlaceholder){

$Display_Title = $Title;
$Display_Help_Title = "Location for $InputValue";
Expand All @@ -338,7 +288,7 @@ function CacheConfig_Display_ROW($Title, $Help, $InputField, $InputValue, $Input
echo "</td>\n";
echo "<td class=\"$tdClass StatsVal\">\n";

echo "<input type=\"text\" id=\"$InputField\" name=\"$InputField\" class=\"form-control fieldInfo-large form-inline\" value=\"$InputValue\" required>";
echo "<input type=\"text\" id=\"$InputField\" name=\"$InputField\" class=\"form-control fieldInfo-large form-inline\" placeholder=\"$InputPlaceholder\" value=\"$InputValue\" required>";

echo "</td>\n";
echo "<td class=\"$tdClass\">\n";
Expand Down
104 changes: 95 additions & 9 deletions assets/plexmovieposter/PMPDLib.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function getData_PreLoad() {

global $isPlaying;
global $mediaThumb_Display, $mediaArt_Status, $mediaArt_Display;
global $RefreshSpeed, $photoModeStatus, $title;
global $RefreshSpeed, $BackgroundArtMode, $FullScreenArtMode, $title;
global $mediaTitle, $mediaSummary, $mediaTagline;
global $topSelection, $topLine, $topCustom, $autoScaleTop, $topScroll;
global $topText, $topSize, $topColor, $topStrokeSize, $topStrokeColor, $topFontEnabled, $topFontID;
Expand Down Expand Up @@ -40,8 +40,11 @@ function getData_PreLoad() {
$RefreshSpeed = 30; // Variables - Legacy
$PMPDDisplay['RefreshSpeed'] = 30; // Variables - Future

$photoModeStatus = FALSE; // Variables - Legacy
$PMPDDisplay['photoModeStatus'] = FALSE; // Variables - Future
$BackgroundArtMode = FALSE; // Variables - Legacy
$PMPDDisplay['BackgroundArtMode'] = FALSE; // Variables - Future

$FullScreenArtMode = FALSE; // Variables - Legacy
$PMPDDisplay['FullScreenArtMode'] = FALSE; // Variables - Future

$title = ""; // Variables - Legacy
$PMPDDisplay['title'] = ""; // Variables - Future
Expand Down Expand Up @@ -138,14 +141,14 @@ function CustomImage_getData() {
// When moved to PHP 8.x use str_contains instead of strpos.

// Global Variables - Input
global $data;
global $data, $PMPDDisplay;
global $pmpCustomDir;
global $customRefreshSpeed, $customImage, $customPath, $customBackgroundArt;
global $customRefreshSpeed, $customImage, $customPath, $customBackgroundArt, $customFullScreenArt;
global $customTopText, $customTopFontSize, $customTopFontColor, $customTopFontOutlineSize, $customTopFontOutlineColor, $customTopFontEnabled, $customTopFontID;
global $customBottomText, $customBottomFontSize, $customBottomFontColor, $customBottomFontOutlineSize, $customBottomFontOutlineColor, $customBottomFontEnabled, $customBottomFontID;

// Global Variables - Output
global $RefreshSpeed, $mediaThumb_Display, $mediaArt_Display, $mediaArt_Status, $photoModeStatus;
global $RefreshSpeed, $mediaThumb_Display, $mediaArt_Display, $mediaArt_Status, $FullScreenArtMode;
global $topText, $topSize, $topColor, $topStrokeSize, $topStrokeColor, $topFontEnabled, $topFontID;
global $bottomText, $bottomSize, $bottomColor, $bottomStrokeSize, $bottomStrokeColor, $bottomFontEnabled, $bottomFontID;

Expand All @@ -154,25 +157,52 @@ function CustomImage_getData() {

if (!empty($customRefreshSpeed)) {
$RefreshSpeed = $customRefreshSpeed;
$PMPDDisplay['RefreshSpeed'] = $customRefreshSpeed;
}

// $topSelection = $nowShowingTop;
$topText = $customTopText;
$PMPDDisplay['topText'] = $customTopText;

$topSize = $customTopFontSize;
$PMPDDisplay['topSize'] = $customTopFontSize;

$topColor = $customTopFontColor;
$PMPDDisplay['topColor'] = $customTopFontColor;

$topStrokeSize = $customTopFontOutlineSize;
$PMPDDisplay['topStrokeSize'] = $customTopFontOutlineSize;

$topStrokeColor = $customTopFontOutlineColor;
$PMPDDisplay['topStrokeColor'] = $customTopFontOutlineColor;

$topFontEnabled = $customTopFontEnabled;
$PMPDDisplay['topFontEnabled'] = $customTopFontEnabled;

$topFontID = $customTopFontID;
$PMPDDisplay['topFontID'] = $customTopFontID;

// $bottomSelection = $nowShowingBottom;
$bottomText = $customBottomText;
$PMPDDisplay['bottomText'] = $customBottomText;

$bottomSize = $customBottomFontSize;
$PMPDDisplay['bottomSize'] = $customBottomFontSize;

$bottomColor = $customBottomFontColor;
$PMPDDisplay['bottomColor'] = $customBottomFontColor;

$bottomStrokeSize = $customBottomFontOutlineSize;
$PMPDDisplay['bottomStrokeSize'] = $customBottomFontOutlineSize;

$bottomStrokeColor = $customBottomFontOutlineColor;
$PMPDDisplay['bottomStrokeColor'] = $customBottomFontOutlineColor;

$bottomFontEnabled = $customBottomFontEnabled;
$PMPDDisplay['bottomFontEnabled'] = $customBottomFontEnabled;

$bottomFontID = $customBottomFontID;
$PMPDDisplay['bottomFontID'] = $customBottomFontID;

if ($customImage == "RANDOM") {
$source = $pmpCustomDir;
Expand Down Expand Up @@ -214,24 +244,80 @@ function CustomImage_getData() {

if ($Validate_IMGPath == TRUE) {
$mediaThumb_Display = "url('$customImage')";
$PMPDDisplay['mediaThumb_Display'] = "url('$customImage')";
}
else {
$mediaThumb_Display = "url('$customPath/$customImage')";
$PMPDDisplay['mediaThumb_Display'] = "url('$customPath/$customImage')";
}

if ($Validate_IMGPath == TRUE) {
$mediaArt_Display = "url('$customImage')";
$PMPDDisplay['mediaArt_Display'] = "url('$customImage')";
}
else {
$mediaArt_Display = "url('$customPath/$customImage')";
$PMPDDisplay['mediaArt_Display'] = "url('$customPath/$customImage')";
}

$mediaArt_Status = $customBackgroundArt;
$PMPDDisplay['mediaArt_Status'] = $customBackgroundArt;

$FullScreenArtMode = $customFullScreenArt;
$PMPDDisplay['FullScreenArtMode'] = $customFullScreenArt;
}

if ($mediaArt_Status == TRUE) {
$mediaThumb_Display = "";
$photoModeStatus = TRUE;
function SetFullScreenMode($SetMode = FALSE) {
// Global Variables - Input
global $PMPDDisplay;
global $mediaArt_Status, $mediaThumb_Display;

// Global Variables - Output
global $FullScreenArtMode;
global $topText, $bottomText;

if ($SetMode == TRUE) {
$mediaArt_Display = $mediaThumb_Display;
$PMPDDisplay['mediaArt_Display'] = $mediaThumb_Display;

$FullScreenArtMode = TRUE;
$PMPDDisplay['FullScreenArtMode'] = TRUE;
}
}

function PMPD_SetResults() {

// Global Variables - Input
global $PMPDDisplay;
global $topLine, $progressBar, $mediaThumb_Display, $mediaArt_Status, $mediaArt_Display, $bottomLine;
global $RefreshSpeed;

// Global Variables - Output
global $results;

// Business Logic
$results = [];

$results['refreshSpeed'] = ($RefreshSpeed);
$results['fullScreenMode'] = $PMPDDisplay['FullScreenArtMode'] ; // Future Use (Issue #48)

if ($PMPDDisplay['FullScreenArtMode'] == TRUE) {
$results['top'] = "";
$results['middle'] = "";
$results['mediaArt'] = $PMPDDisplay['mediaArt_Display'];
$results['bottom'] = "";
}
else {
$results['top'] = $topLine . $progressBar;
$results['middle'] = $mediaThumb_Display;

if ($mediaArt_Status) {
$results['mediaArt'] = $mediaArt_Display;
} else {
$results['mediaArt'] = "";
}

$results['bottom'] = $bottomLine;
}
}
?>
Loading

0 comments on commit c832299

Please sign in to comment.