dlg.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <?php
  2. class Dlg extends Handler_Protected {
  3. private $param;
  4. private $params;
  5. function before($method) {
  6. if (parent::before($method)) {
  7. header("Content-Type: text/html"); # required for iframe
  8. $this->param = $_REQUEST["param"];
  9. return true;
  10. }
  11. return false;
  12. }
  13. function importOpml() {
  14. print __("If you have imported labels and/or filters, you might need to reload preferences to see your new data.") . "</p>";
  15. print "<div class=\"prefFeedOPMLHolder\">";
  16. print "<ul class='nomarks'>";
  17. $opml = new Opml($_REQUEST);
  18. $opml->opml_import($_SESSION["uid"]);
  19. print "</ul>";
  20. print "</div>";
  21. print "<div align='center'>";
  22. print "<button dojoType=\"dijit.form.Button\"
  23. onclick=\"dijit.byId('opmlImportDlg').execute()\">".
  24. __('Close this window')."</button>";
  25. print "</div>";
  26. print "</div>";
  27. //return;
  28. }
  29. function pubOPMLUrl() {
  30. $url_path = Opml::opml_publish_url();
  31. print __("Your Public OPML URL is:");
  32. print "<div class=\"tagCloudContainer\">";
  33. print "<a id='pub_opml_url' href='$url_path' target='_blank'>$url_path</a>";
  34. print "</div>";
  35. print "<div align='center'>";
  36. print "<button dojoType=\"dijit.form.Button\" onclick=\"return Helpers.OPML.changeKey()\">".
  37. __('Generate new URL')."</button> ";
  38. print "<button dojoType=\"dijit.form.Button\" onclick=\"return CommonDialogs.closeInfoBox()\">".
  39. __('Close this window')."</button>";
  40. print "</div>";
  41. //return;
  42. }
  43. function explainError() {
  44. print "<div class=\"errorExplained\">";
  45. if ($this->param == 1) {
  46. print __("Update daemon is enabled in configuration, but daemon process is not running, which prevents all feeds from updating. Please start the daemon process or contact instance owner.");
  47. $stamp = (int) file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp");
  48. print "<p>" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp);
  49. }
  50. if ($this->param == 3) {
  51. print __("Update daemon is taking too long to perform a feed update. This could indicate a problem like crash or a hang. Please check the daemon process or contact instance owner.");
  52. $stamp = (int) file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp");
  53. print "<p>" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp);
  54. }
  55. print "</div>";
  56. print "<div align='center'>";
  57. print "<button onclick=\"return CommonDialogs.closeInfoBox()\">".
  58. __('Close this window')."</button>";
  59. print "</div>";
  60. //return;
  61. }
  62. function printTagCloud() {
  63. print "<div class=\"tagCloudContainer\">";
  64. // from here: http://www.roscripts.com/Create_tag_cloud-71.html
  65. $sth = $this->pdo->prepare("SELECT tag_name, COUNT(post_int_id) AS count
  66. FROM ttrss_tags WHERE owner_uid = ?
  67. GROUP BY tag_name ORDER BY count DESC LIMIT 50");
  68. $sth->execute([$_SESSION['uid']]);
  69. $tags = array();
  70. while ($line = $sth->fetch()) {
  71. $tags[$line["tag_name"]] = $line["count"];
  72. }
  73. if(count($tags) == 0 ){ return; }
  74. ksort($tags);
  75. $max_size = 32; // max font size in pixels
  76. $min_size = 11; // min font size in pixels
  77. // largest and smallest array values
  78. $max_qty = max(array_values($tags));
  79. $min_qty = min(array_values($tags));
  80. // find the range of values
  81. $spread = $max_qty - $min_qty;
  82. if ($spread == 0) { // we don't want to divide by zero
  83. $spread = 1;
  84. }
  85. // set the font-size increment
  86. $step = ($max_size - $min_size) / ($spread);
  87. // loop through the tag array
  88. foreach ($tags as $key => $value) {
  89. // calculate font-size
  90. // find the $value in excess of $min_qty
  91. // multiply by the font-size increment ($size)
  92. // and add the $min_size set above
  93. $size = round($min_size + (($value - $min_qty) * $step));
  94. $key_escaped = str_replace("'", "\\'", $key);
  95. echo "<a href=\"#\" onclick=\"Feeds.open({feed:'$key_escaped'}) \" style=\"font-size: " .
  96. $size . "px\" title=\"$value articles tagged with " .
  97. $key . '">' . $key . '</a> ';
  98. }
  99. print "</div>";
  100. print "<div align='center'>";
  101. print "<button dojoType=\"dijit.form.Button\"
  102. onclick=\"return CommonDialogs.closeInfoBox()\">".
  103. __('Close this window')."</button>";
  104. print "</div>";
  105. }
  106. function generatedFeed() {
  107. $this->params = explode(":", $this->param, 3);
  108. $feed_id = $this->params[0];
  109. $is_cat = (bool) $this->params[1];
  110. $key = get_feed_access_key($feed_id, $is_cat);
  111. $url_path = htmlspecialchars($this->params[2]) . "&key=" . $key;
  112. $feed_title = Feeds::getFeedTitle($feed_id, $is_cat);
  113. print "<div>".T_sprintf("%s can be accessed via the following secret URL:", $feed_title)."</div>";
  114. print "<div class=\"tagCloudContainer\">";
  115. print "<a id='gen_feed_url' href='$url_path' target='_blank'>$url_path</a>";
  116. print "</div>";
  117. print "<div align='center'>";
  118. print "<button dojoType=\"dijit.form.Button\" onclick=\"return CommonDialogs.genUrlChangeKey('$feed_id', '$is_cat')\">".
  119. __('Generate new URL')."</button> ";
  120. print "<button dojoType=\"dijit.form.Button\" onclick=\"return CommonDialogs.closeInfoBox()\">".
  121. __('Close this window')."</button>";
  122. print "</div>";
  123. //return;
  124. }
  125. function defaultPasswordWarning() {
  126. print_warning(__("You are using default tt-rss password. Please change it in the Preferences (Personal data / Authentication)."));
  127. print "<div align='center'>";
  128. print "<button dojoType=\"dijit.form.Button\" onclick=\"document.location.href = 'prefs.php'\">".
  129. __('Open Preferences')."</button> ";
  130. print "<button dojoType=\"dijit.form.Button\"
  131. onclick=\"return CommonDialogs.closeInfoBox()\">".
  132. __('Close this window')."</button>";
  133. print "</div>";
  134. }
  135. }