display.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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 '<form action="' . $_SERVER['PHP_SELF'] . '?series=' . urlencode($series) . '" method="post" data-ajax="false">';
  26. echo '<input type="hidden" name="series" value="' . htmlspecialchars($series) . '"/>';
  27. # Series flags
  28. echo '<h2>Series Parameters</h2>';
  29. echo '<div data-role="fieldcontain">';
  30. foreach ($EXISTS_FILES as $file) {
  31. if ($file == 'skip' || !$flags['skip']) {
  32. $file_html = htmlspecialchars($file);
  33. echo '<label for="' . $file_html . '">' . $file_html . '</label>';
  34. echo '<select data-role="slider" id="' . $file_html . '" name="' . $file_html . '"/>';
  35. echo '<option value="0">Off</option>';
  36. echo '<option value="1"';
  37. if ($flags[ $file ] !== false) {
  38. echo ' selected';
  39. }
  40. echo '>On</option>';
  41. echo '</select><br/>';
  42. }
  43. }
  44. if (!$flags['skip']) {
  45. foreach ($CONTENT_FILES as $file) {
  46. $file_html = htmlspecialchars($file);
  47. echo '<label for="' . $file_html . '">' . $file_html . ':</label>';
  48. echo '<input data-inline="true" type="text" size="40" id="' . $file_html . '" name="' . $file_html . '"';
  49. if ($flags[ $file ]) {
  50. echo ' value="' . htmlspecialchars($flags[ $file ]) . '"';
  51. }
  52. echo '>';
  53. }
  54. }
  55. echo '</div>';
  56. # Save button
  57. echo '<p><input type="submit" name="Save" value="Save"/></p>';
  58. # Seasons
  59. if (!$flags['skip']) {
  60. echo '<h2>Season Parameters</h2>';
  61. # Existing seasons
  62. echo '<dl>';
  63. foreach ($seasons as $season => $monitored) {
  64. $season_html = htmlspecialchars($season);
  65. $episodes = findEpisodes($series, $season);
  66. $count = count($episodes);
  67. $max = @max(array_keys($episodes));
  68. if (!$max) {
  69. $max = 0;
  70. }
  71. echo '<h3>Season ' . $season_html . '</h3>';
  72. if ($season) {
  73. echo '<label><select data-role="slider" name="season_' . $season_html . '"/>';
  74. echo '<option value="0">Off</option>';
  75. echo '<option value="1"';
  76. if ($monitored !== false) {
  77. echo ' selected';
  78. }
  79. echo '>On</option>';
  80. echo '</select></label>';
  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" size="2" 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. # 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. # Wrap the entire jquery section
  129. echo '<div data-role="page" id="linkbar-page">';
  130. # Header
  131. echo '<div data-role="header">';
  132. echo '<h1>UberZach TV</h1>';
  133. if (authenticated()) {
  134. echo '<a href="' . $LOGIN_PAGE . '?logout=1" class="ui-btn-right" data-ajax="false">Logout: ' . username() . '</a>';
  135. } else {
  136. echo '<a href="' . $LOGIN_PAGE . '" class="ui-btn-right" data-ajax="false">Login</a>';
  137. }
  138. echo '</div>';
  139. # Wrap all the sorted/filtered content
  140. echo '<div data-role="content">';
  141. # Display the sorter
  142. echo '<div id="sorter">';
  143. echo '<ul data-role="listview">';
  144. echo '<li><span>#</span></li>';
  145. foreach (range('A', 'Z') as $char) {
  146. echo '<li><span>' . $char . '</span></li>';
  147. }
  148. echo '</ul>';
  149. echo '</div>';
  150. # Sort by "sortTitle" -- an approximation of the Plex sort title
  151. $sorted_series = array();
  152. foreach ($all_series as $series => $seasons) {
  153. $sorted_series[ $series ] = sortTitle($series);
  154. }
  155. asort($sorted_series, SORT_FLAG_CASE | SORT_NATURAL);
  156. # Display all series
  157. echo '<ul data-role="listview" data-filter="true" data-autodividers="true" id="sortedList">';
  158. foreach ($sorted_series as $series => $sort) {
  159. # Determine if the series has any monitored seasons
  160. $monitored = false;
  161. foreach ($all_series[ $series ] as $season => $status) {
  162. if ($status) {
  163. $monitored = true;
  164. }
  165. }
  166. echo '<li><a href="?series=' . urlencode($series) . '">';
  167. if ($monitored) {
  168. echo '<img src="tv.png" class="ui-li-icon ui-corner-none">';
  169. }
  170. echo htmlspecialchars($sort);
  171. echo '<span class="ui-li-count">' . count($all_series[ $series ]) . '</span>';
  172. echo '</a></li>';
  173. }
  174. echo '</ul>';
  175. # End the sorted/filtered content
  176. echo '</div>';
  177. # Add a series
  178. echo '<div data-role="footer"><p>';
  179. echo '<form action="' . $_SERVER['PHP_SELF'] . '" method="post" data-ajax="false">';
  180. echo '<label>TheTVDB ID or URL: <input type="text" name="series_add"/></label>';
  181. echo '<input type="submit" value="Add Series"/>';
  182. echo '</form>';
  183. echo '</p></div>';
  184. # End the jquery section
  185. echo '</div>';
  186. }
  187. ?>