display.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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 '<p>';
  30. foreach ($EXISTS_FILES as $file) {
  31. if ($file == 'skip' || !$flags['skip']) {
  32. $file_html = htmlspecialchars($file);
  33. echo '<label><input value="1" type="checkbox" name="' . $file_html . '" ';
  34. if ($flags[ $file ]) {
  35. echo 'checked="checked"';
  36. }
  37. echo '/> ' . $file_html . '</label><br/>';
  38. }
  39. }
  40. if (!$flags['skip']) {
  41. foreach ($CONTENT_FILES as $file) {
  42. $file_html = htmlspecialchars($file);
  43. echo '<label><input type="text" size="40" name="' . $file_html . '" ';
  44. if ($flags[ $file ]) {
  45. echo 'value="' . htmlspecialchars($flags[ $file ]) . '"';
  46. }
  47. echo '/> ' . $file_html . '</label><br/>';
  48. }
  49. echo '</p>';
  50. }
  51. # Seasons
  52. if (!$flags['skip']) {
  53. echo '<h2>Season Parameters</h2>';
  54. # Existing seasons
  55. echo '<dl>';
  56. foreach ($seasons as $season => $monitored) {
  57. $season_html = htmlspecialchars($season);
  58. $episodes = findEpisodes($series, $season);
  59. echo '<h3>Season ' . $season_html . '</h3>';
  60. echo '<label>Monitored: <input type="checkbox" value="1" name="season_' . $season_html . '" ';
  61. if ($monitored !== false) {
  62. echo 'checked="checked"';
  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 '<hr/>';
  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. require 'config.php';
  92. global $TV_PATH;
  93. $all_series = allSeriesSeasons($TV_PATH);
  94. # Wrap the entire jquery section
  95. echo '<div data-role="page" id="linkbar-page">';
  96. # Header
  97. echo '<div data-role="header">';
  98. echo '<h1>UberZach TV</h1>';
  99. if (authenticated()) {
  100. echo '<a href="' . $LOGIN_PAGE . '?logout=1" class="ui-btn-right" data-ajax="false">Logout: ' . username() . '</a>';
  101. } else {
  102. echo '<a href="' . $LOGIN_PAGE . '" class="ui-btn-right" data-ajax="false">Login</a>';
  103. }
  104. echo '</div>';
  105. # Wrap all the sorted/filtered content
  106. echo '<div data-role="content">';
  107. # Display the sorter
  108. echo '<div id="sorter">';
  109. echo '<ul data-role="listview">';
  110. echo '<li><span>#</span></li>';
  111. foreach (range('A', 'Z') as $char) {
  112. echo '<li><span>' . $char . '</span></li>';
  113. }
  114. echo '</ul>';
  115. echo '</div>';
  116. # Sort by "sortTitle" -- an approximation of the Plex sort title
  117. $sorted_series = array();
  118. foreach ($all_series as $series => $seasons) {
  119. $sorted_series[ $series ] = sortTitle($series);
  120. }
  121. asort($sorted_series, SORT_FLAG_CASE | SORT_NATURAL);
  122. # Display all series
  123. echo '<ul data-role="listview" data-filter="true" data-autodividers="true" id="sortedList">';
  124. foreach ($sorted_series as $series => $sort) {
  125. # Determine if the series has any monitored seasons
  126. $monitored = false;
  127. foreach ($all_series[ $series ] as $season => $status) {
  128. if ($status) {
  129. $monitored = true;
  130. }
  131. }
  132. echo '<li><a href="?series=' . urlencode($series) . '">';
  133. if ($monitored) {
  134. echo '<img src="tv.png" class="ui-li-icon ui-corner-none">';
  135. }
  136. echo htmlspecialchars($sort);
  137. echo '<span class="ui-li-count">' . count($all_series[ $series ]) . '</span>';
  138. echo '</a></li>';
  139. }
  140. echo '</ul>';
  141. # End the sorted/filtered content
  142. echo '</div>';
  143. # Add a series
  144. echo '<div data-role="footer"><p>';
  145. echo '<form action="' . $_SERVER['PHP_SELF'] . '" method="post" data-ajax="false">';
  146. echo '<label>TheTVDB ID or URL: <input type="text" name="series_add"/></label>';
  147. echo '<input type="submit" value="Add Series"/>';
  148. echo '</form>';
  149. echo '</p></div>';
  150. # End the jquery section
  151. echo '</div>';
  152. }
  153. ?>