display.php 6.1 KB

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