display.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <?
  2. require 'config.php';
  3. function printSeries($series) {
  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. echo '</div>';
  19. # Form
  20. echo '<form action="' . $_SERVER['PHP_SELF'] . '?series=' . urlencode($series) . '" method="post" data-ajax="false">';
  21. echo '<input type="hidden" name="series" value="' . htmlspecialchars($series) . '"/>';
  22. # Series flags
  23. echo '<h2>Series Parameters</h2>';
  24. echo '<p>';
  25. foreach ($EXISTS_FILES as $file) {
  26. if ($file == 'skip' || !$flags['skip']) {
  27. $file_html = htmlspecialchars($file);
  28. echo '<label><input value="1" type="checkbox" name="' . $file_html . '" ';
  29. if ($flags[ $file ]) {
  30. echo 'checked="checked"';
  31. }
  32. echo '/> ' . $file_html . '</label><br/>';
  33. }
  34. }
  35. if (!$flags['skip']) {
  36. foreach ($CONTENT_FILES as $file) {
  37. $file_html = htmlspecialchars($file);
  38. echo '<label><input type="text" size="40" name="' . $file_html . '" ';
  39. if ($flags[ $file ]) {
  40. echo 'value="' . htmlspecialchars($flags[ $file ]) . '"';
  41. }
  42. echo '/> ' . $file_html . '</label><br/>';
  43. }
  44. echo '</p>';
  45. }
  46. # Seasons
  47. if (!$flags['skip']) {
  48. echo '<h2>Season Parameters</h2>';
  49. # Existing seasons
  50. echo '<dl>';
  51. foreach ($seasons as $season => $monitored) {
  52. $season_html = htmlspecialchars($season);
  53. $episodes = findEpisodes($series, $season);
  54. echo '<dt>Season ' . $season_html . '</dt>';
  55. echo '<dd><label>Monitored: <input type="checkbox" value="1" name="season_' . $season_html . '" ';
  56. if ($monitored !== false) {
  57. echo 'checked="checked"';
  58. }
  59. echo '/></label><br/>';
  60. echo '<label>Search URL: <input type="text" size="150" name="url_' . $season_html . '" value="';
  61. if ($monitored !== false && $monitored !== true) {
  62. echo htmlspecialchars($monitored);
  63. }
  64. echo '"/></label><br/>';
  65. echo '<input type="submit" name="season_del_' . $season_html . '" value="Delete"><br/>';
  66. echo 'Episode count: ' . count($episodes) . '<br/>';
  67. echo 'Highest episode number: ' . @max(array_keys($episodes)) . '<br/>';
  68. echo '</dd>';
  69. }
  70. echo '</dl>';
  71. # Add a season
  72. $next_season = @max(array_keys($seasons)) + 1;
  73. echo '<p>Add season: ';
  74. echo '<input type="text" size="2" name="season_add" value="' . htmlspecialchars($next_season) . '"/>';
  75. echo '<input type="submit" name="AddSeason" value="Add Season">';
  76. echo '</p>';
  77. }
  78. # Save button
  79. echo '<p><input type="submit" name="Save" value="Save"/></p>';
  80. # End Form
  81. echo '</form>';
  82. # TheTVDB Frame
  83. $url_html = htmlspecialchars(TVDBURL($flags['tvdb-id'], $flags['tvdb-lid']));
  84. echo '<h2>The TVDB</h2>';
  85. echo '<p><a target="_blank" href="' . $url_html . '">' . $url_html . '</a></p>';
  86. echo '<iframe height="5000" style="width: 90%; display: block; margin: 0 auto;" src="' . $url_html . '">';
  87. echo '</iframe>';
  88. }
  89. # Print a DL of all series and note the available and monitored seasons
  90. function printAllSeries() {
  91. global $TV_PATH;
  92. $all_series = allSeriesSeasons($TV_PATH);
  93. # Wrap the entire jquery section
  94. echo '<div data-role="page" id="linkbar-page">';
  95. # Header
  96. echo '<div data-role="header">';
  97. echo '<h1>UberZach TV</h1>';
  98. echo '</div>';
  99. # Wrap all the sorted/filtered content
  100. echo '<div data-role="content">';
  101. # Display the sorter
  102. echo '<div id="sorter">';
  103. echo '<ul data-role="listview">';
  104. echo '<li><span>#</span></li>';
  105. foreach (range('A', 'Z') as $char) {
  106. echo '<li><span>' . $char . '</span></li>';
  107. }
  108. echo '</ul>';
  109. echo '</div>';
  110. # Sort by "sortTitle" -- an approximation of the Plex sort title
  111. $sorted_series = array();
  112. foreach ($all_series as $series => $seasons) {
  113. $sorted_series[ $series ] = sortTitle($series);
  114. }
  115. asort($sorted_series, SORT_FLAG_CASE | SORT_NATURAL);
  116. # Display all series
  117. echo '<ul data-role="listview" data-filter="true" data-autodividers="true" id="sortedList">';
  118. foreach ($sorted_series as $series => $sort) {
  119. # Determine if the series has any monitored seasons
  120. $monitored = false;
  121. foreach ($all_series[ $series ] as $season => $status) {
  122. if ($status) {
  123. $monitored = true;
  124. }
  125. }
  126. echo '<li><a href="?series=' . urlencode($series) . '">';
  127. if ($monitored) {
  128. echo '<img src="tv.png" class="ui-li-icon ui-corner-none">';
  129. }
  130. echo htmlspecialchars($sort);
  131. echo '<span class="ui-li-count">' . count($all_series[ $series ]) . '</span>';
  132. echo '</a></li>';
  133. }
  134. echo '</ul>';
  135. # End the sorted/filtered content
  136. echo '</div>';
  137. # Add a series
  138. echo '<div data-role="footer"><p>';
  139. echo '<form action="' . $_SERVER['PHP_SELF'] . '" method="post" data-ajax="false">';
  140. echo '<label>TheTVDB ID or URL: <input type="text" name="series_add"/></label>';
  141. echo '<input type="submit" value="Add Series"/>';
  142. echo '</form>';
  143. echo '</p></div>';
  144. # End the jquery section
  145. echo '</div>';
  146. }
  147. ?>