display.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <?
  2. function printSeries($series) {
  3. require 'config.php';
  4. global $EXISTS_FILES;
  5. global $CONTENT_FILES;
  6. # Ensure our series name is reasonable
  7. $series_html = htmlspecialchars(displayTitle($series));
  8. if (!seriesExists($series)) {
  9. die('Unknown series: ' . $series_html);
  10. }
  11. # Grab the flag and season data
  12. $flags = readFlags($series);
  13. $seasons = findSeasons($series);
  14. # Header
  15. echo '<div data-role="header">';
  16. echo '<h1>' . $series_html . '</h1>';
  17. echo '<a href="' . $_SERVER['PHP_SELF'] . '" data-icon="arrow-l" data-iconpos="notext" data-ajax="false">Back</a>';
  18. if (authenticated()) {
  19. echo '<a href="' . $LOGIN_PAGE . '?logout=1" data-ajax="false">Logout: ' . username() . '</a>';
  20. } else {
  21. echo '<a href="' . $LOGIN_PAGE . '" data-ajax="false">Login</a>';
  22. }
  23. echo '</div>';
  24. # Wrap all the content
  25. echo '<div role="main" class="ui-content" style="width: 95%; margin-left: auto; margin-right: auto;">';
  26. # Form
  27. echo '<form action="' . $_SERVER['PHP_SELF'] . '?series=' . urlencode($series) . '" method="post" data-ajax="false">';
  28. echo '<input type="hidden" name="series" value="' . htmlspecialchars($series) . '"/>';
  29. # Series flags
  30. echo '<h2>Series Parameters</h2>';
  31. echo '<fieldset><div data-role="fieldcontain">';
  32. foreach ($EXISTS_FILES as $file) {
  33. if ($file == 'skip' || !$flags['skip']) {
  34. $file_html = htmlspecialchars($file);
  35. echo '<label for="' . $file_html . '">' . $file_html . '</label>';
  36. echo '<input type="checkbox" data-inline="true" data-role="flipswitch" value="1" id="' .
  37. $file_html . '" name="' . $file_html . '"';
  38. if ($flags[ $file ] !== false) {
  39. echo ' checked';
  40. }
  41. echo '/><br style="clear: both" />';
  42. }
  43. }
  44. echo '</div></fieldset>';
  45. if (!$flags['skip']) {
  46. echo '<fieldset><div data-role="fieldcontain">';
  47. foreach ($CONTENT_FILES as $file) {
  48. $file_html = htmlspecialchars($file);
  49. echo '<label for="' . $file_html . '">' . $file_html . ':</label>';
  50. echo '<input type="text" data-inline="true" id="' . $file_html . '" name="' . $file_html . '"';
  51. if ($flags[ $file ]) {
  52. echo ' value="' . htmlspecialchars($flags[ $file ]) . '"';
  53. }
  54. echo '>';
  55. }
  56. echo '</div></fieldset>';
  57. }
  58. # Save button
  59. echo '<p><input type="submit" name="Save" value="Save"/></p>';
  60. # Seasons
  61. if (!$flags['skip']) {
  62. echo '<h2>Season Parameters</h2>';
  63. # Existing seasons
  64. echo '<dl>';
  65. foreach ($seasons as $season => $monitored) {
  66. $season_html = htmlspecialchars($season);
  67. $episodes = findEpisodes($series, $season);
  68. $count = count($episodes);
  69. $max = @max(array_keys($episodes));
  70. if (!$max) {
  71. $max = 0;
  72. }
  73. echo '<h3>Season ' . $season_html . '</h3>';
  74. if ($season) {
  75. echo '<input type="checkbox" data-inline="true" data-role="flipswitch" value="1"'.
  76. ' name="season_' . $season_html . '"';
  77. if ($monitored !== false) {
  78. echo ' checked';
  79. }
  80. echo '/>';
  81. }
  82. if ($count) {
  83. echo '<div data-role="fieldcontain">';
  84. echo '<label for="episodes_' . $season_html . '">Episodes';
  85. if ($count == $max) {
  86. echo ' (' . $count . ')';
  87. } else {
  88. echo ' (' . $count . '/' . $max . ')';
  89. }
  90. echo '</label>';
  91. echo '<select id="episodes_' . $season_html . '">';
  92. foreach ($episodes as $num => $episode) {
  93. echo '<option>' . htmlspecialchars(sprintf('%02d', $num) . ' - ' . $episode) . '</option>';
  94. }
  95. echo '</select></label>';
  96. echo '</div>';
  97. } else {
  98. echo '<input type="submit" name="season_del_' . $season_html . '" value="Delete Empty Season"><br/>';
  99. }
  100. }
  101. echo '</dl>';
  102. # Save button
  103. echo '<p><input type="submit" name="Save" value="Save"/></p>';
  104. # Add a season
  105. echo '<h2>Add Season</h2>';
  106. $next_season = @max(array_keys($seasons)) + 1;
  107. echo '<div data-role="fieldcontain">';
  108. echo '<label for="season_add">';
  109. echo '<input pattern="[0-9]*" type="text" id="season_add" name="season_add" value="' . htmlspecialchars($next_season) . '"/>';
  110. echo '</label>';
  111. echo '<input type="submit" id="season_add" name="AddSeason" value="Add Season">';
  112. echo '</div>';
  113. }
  114. # End Form
  115. echo '</form>';
  116. echo '</div>';
  117. # TheTVDB Frame
  118. $url_html = htmlspecialchars(TVDBURL($flags['tvdb-id'], $flags['tvdb-lid']));
  119. echo '<h2>The TVDB</h2>';
  120. echo '<p><a target="_blank" href="' . $url_html . '">' . $url_html . '</a></p>';
  121. echo '<iframe height="1000" style="width: 95%; display: block; margin: 0 auto;" id="tvdb_iframe" src="' . $url_html . '">';
  122. echo '</iframe>';
  123. echo '<script type="text/javascript">';
  124. echo 'function tvdb_iframe_height() { $("#tvdb_iframe").attr("height", document.body.offsetHeight * 0.95); }';
  125. echo '$(window).ready(tvdb_iframe_height);';
  126. echo '$(window).resize(tvdb_iframe_height);';
  127. echo '</script>';
  128. }
  129. # Print a DL of all series and note the available and monitored seasons
  130. function printAllSeries() {
  131. require 'config.php';
  132. global $TV_PATH;
  133. $all_series = allSeriesSeasons($TV_PATH);
  134. # Header
  135. echo '<div data-role="header">';
  136. echo '<h1>UberZach TV</h1>';
  137. if (authenticated()) {
  138. echo '<a href="' . $LOGIN_PAGE . '?logout=1" class="ui-btn-right" data-ajax="false">Logout: ' . username() . '</a>';
  139. } else {
  140. echo '<a href="' . $LOGIN_PAGE . '" class="ui-btn-right" data-ajax="false">Login</a>';
  141. }
  142. echo '</div>';
  143. # Wrap all the content
  144. echo '<div role="main" class="ui-content">';
  145. # Sort by "sortTitle" -- an approximation of the Plex sort title
  146. $sorted_series = array();
  147. foreach ($all_series as $series => $seasons) {
  148. $sorted_series[ $series ] = sortTitle($series);
  149. }
  150. asort($sorted_series, SORT_FLAG_CASE | SORT_NATURAL);
  151. # Display all series
  152. echo '<ul data-role="listview" data-filter="true" data-autodividers="true" id="sortedList">';
  153. foreach ($sorted_series as $series => $sort) {
  154. # Determine if the series has any monitored seasons
  155. $monitored = false;
  156. foreach ($all_series[ $series ] as $season => $status) {
  157. if ($status) {
  158. $monitored = true;
  159. }
  160. }
  161. echo '<li><a href="?series=' . urlencode($series) . '">';
  162. if ($monitored) {
  163. echo '<img src="tv.png" class="ui-li-icon ui-corner-none" alt="Currently Airing" />';
  164. }
  165. echo htmlspecialchars($sort);
  166. echo '<span class="ui-li-count">' . count($all_series[ $series ]) . '</span>';
  167. echo '</a></li>';
  168. }
  169. echo '</ul>';
  170. # End the sorted/filtered content
  171. echo '</div>';
  172. # Add a series
  173. echo '<form action="' . $_SERVER['PHP_SELF'] . '" method="post" data-ajax="false">';
  174. echo '<div data-role="footer"><p>';
  175. echo '<label>TheTVDB ID or URL: <input type="text" name="series_add"/></label>';
  176. echo '<input type="submit" value="Add Series"/>';
  177. echo '</p></div>';
  178. echo '</form>';
  179. }
  180. ?>