display.php 6.5 KB

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