فهرست منبع

Merge pull request #1793 from jessehickman/patch-9

Adding "Target URL" under Homepage Item > Calendar Settings
causefx 4 سال پیش
والد
کامیت
1f85e855ab
5فایلهای تغییر یافته به همراه45 افزوده شده و 13 حذف شده
  1. 18 3
      api/functions/option-functions.php
  2. 7 3
      api/homepage/lidarr.php
  3. 8 3
      api/homepage/radarr.php
  4. 7 3
      api/homepage/sonarr.php
  5. 5 1
      js/functions.js

+ 18 - 3
api/functions/option-functions.php

@@ -447,6 +447,14 @@ trait OptionsFunction
 					'attr' => 'data-original="' . $this->config[$name] . '"'
 				];
 				break;
+			case 'calendarlinkurl':
+				$settingMerge = [
+					'type' => 'select',
+					'label' => 'Target URL',
+					'help' => 'Set the primary URL used when clicking on calendar icon.',
+					'options' => $this->makeOptionsFromValues($this->config[str_replace('CalendarLink','',$name).'URL'], true, 'Use Default'),
+				];
+				break;
 			default:
 				$settingMerge = [
 					'type' => strtolower($type),
@@ -463,9 +471,16 @@ trait OptionsFunction
 		return $setting;
 	}
 
-	public function makeOptionsFromValues($values = null)
+	public function makeOptionsFromValues($values = null, $appendBlank = null, $blankLabel = null)
 	{
-		$formattedValues = [];
+		if ($appendBlank === true){
+			$formattedValues[] = [
+				'name' => (!empty($blankLabel)) ? $blankLabel : 'Select option...',
+				'value' => ''
+			];
+		} else {
+			$formattedValues = [];
+		}
 		if (strpos($values, ',') !== false) {
 			$explode = explode(',', $values);
 			foreach ($explode as $item) {
@@ -1312,4 +1327,4 @@ trait OptionsFunction
 			)
 		);
 	}
-}
+}

+ 7 - 3
api/homepage/lidarr.php

@@ -42,6 +42,7 @@ trait LidarrHomepageItem
 					$this->settingsOption('calendar-locale', 'calendarLocale'),
 					$this->settingsOption('calendar-limit', 'calendarLimit'),
 					$this->settingsOption('refresh', 'calendarRefresh'),
+					$this->settingsOption('calendar-link-url', 'lidarrCalendarLink'),
 				],
 				'Test Connection' => [
 					$this->settingsOption('blank', null, ['label' => 'Please Save before Testing']),
@@ -237,10 +238,13 @@ trait LidarrHomepageItem
 					$fanart = str_replace('http://', 'https://', $image['url']);
 				}
 			}
-			$href = "";
-			if (!empty($this->config['lidarrURL'])){
+			$href = $this->config['lidarrCalendarLink'] ?? '';
+			if (empty($href) && !empty($this->config['lidarrURL'])){
 				$href_arr = explode(',',$this->config['lidarrURL']);
-				$href = reset($href_arr) . '/artist/' . $child['artist']['foreignArtistId'];
+				$href = reset($href_arr);
+			}
+			if (!empty($href)){
+				$href = $href . '/artist/' . $child['artist']['foreignArtistId'];
 				$href = str_replace("//artist/","/artist/",$href);
 			}
 			$details = array(

+ 8 - 3
api/homepage/radarr.php

@@ -48,6 +48,8 @@ trait RadarrHomepageItem
 					$this->settingsOption('calendar-locale', 'calendarLocale'),
 					$this->settingsOption('calendar-limit', 'calendarLimit'),
 					$this->settingsOption('refresh', 'calendarRefresh'),
+					$this->settingsOption('calendar-link-url', 'radarrCalendarLink'),
+					$this->settingsOption('blank', null),
 					$this->settingsOption('switch', 'radarrUnmonitored', ['label' => 'Show Unmonitored']),
 					$this->settingsOption('switch', 'radarrPhysicalRelease', ['label' => 'Show Physical Releases']),
 					$this->settingsOption('switch', 'radarrDigitalRelease', ['label' => 'Show Digital Releases']),
@@ -322,10 +324,13 @@ trait RadarrHomepageItem
 					}
 				}
 				$alternativeTitles = empty($alternativeTitles) ? "" : substr($alternativeTitles, 0, -2);
-				$href = "";
-				if (!empty($this->config['radarrURL'])){
+				$href = $this->config['radarrCalendarLink'] ?? '';
+				if (empty($href) && !empty($this->config['radarrURL'])){
 					$href_arr = explode(',',$this->config['radarrURL']);
-					$href = reset($href_arr) . '/movie/' . $movieID;
+					$href = reset($href_arr);
+				}
+				if (!empty($href)){
+					$href = $href . '/movie/' . $movieID;
 					$href = str_replace("//movie/","/movie/",$href);
 				}
 				$details = array(

+ 7 - 3
api/homepage/sonarr.php

@@ -52,6 +52,7 @@ trait SonarrHomepageItem
 					$this->settingsOption('calendar-locale', 'calendarLocale'),
 					$this->settingsOption('calendar-limit', 'calendarLimit'),
 					$this->settingsOption('refresh', 'calendarRefresh'),
+					$this->settingsOption('calendar-link-url', 'sonarrCalendarLink'),
 					$this->settingsOption('switch', 'sonarrUnmonitored', ['label' => 'Show Unmonitored']),
 				],
 				'Test Connection' => [
@@ -289,10 +290,13 @@ trait SonarrHomepageItem
 				}
 			}
 			$bottomTitle = 'S' . sprintf("%02d", $child['seasonNumber']) . 'E' . sprintf("%02d", $child['episodeNumber']) . ' - ' . $child['title'];
-			$href = "";
-			if (!empty($this->config['sonarrURL'])){
+			$href = $this->config['sonarrCalendarLink'] ?? '';
+			if (empty($href) && !empty($this->config['sonarrURL'])){
 				$href_arr = explode(',',$this->config['sonarrURL']);
-				$href = reset($href_arr) . '/series/' . preg_replace('/[^A-Za-z0-9. -]/', '', preg_replace('/[[:space:]]+/', '-', $seriesName));
+				$href = reset($href_arr);
+			}
+			if (!empty($href)){
+				$href = $href . '/series/' . preg_replace('/[^A-Za-z0-9. -]/', '', preg_replace('/[[:space:]]+/', '-', $seriesName));
 				$href = str_replace("//series/","/series/",$href);
 			}
 			$details = array(

+ 5 - 1
js/functions.js

@@ -6966,7 +6966,11 @@ function buildPVRLink(href, ico){
 		return `
 		<div class="btn btn-inverse waves-effect waves-light" type="button" onclick="window.open('${href}')" style="${styleOverride}"></div>
 		`;
-	} 
+	} else {
+		return `
+		 
+		`;
+	}
 }
 function buildCalendarMetadata(array){
 	var metadata = '';