dlg.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <?php
  2. class Dlg extends Handler_Protected {
  3. private $param;
  4. function before($method) {
  5. if (parent::before($method)) {
  6. header("Content-Type: text/html"); # required for iframe
  7. $this->param = $this->dbh->escape_string($_REQUEST["param"]);
  8. return true;
  9. }
  10. return false;
  11. }
  12. function importOpml() {
  13. print __("If you have imported labels and/or filters, you might need to reload preferences to see your new data.") . "</p>";
  14. print "<div class=\"prefFeedOPMLHolder\">";
  15. $this->dbh->query("BEGIN");
  16. print "<ul class='nomarks'>";
  17. $opml = new Opml($_REQUEST);
  18. $opml->opml_import($_SESSION["uid"]);
  19. $this->dbh->query("COMMIT");
  20. print "</ul>";
  21. print "</div>";
  22. print "<div align='center'>";
  23. print "<button dojoType=\"dijit.form.Button\"
  24. onclick=\"dijit.byId('opmlImportDlg').execute()\">".
  25. __('Close this window')."</button>";
  26. print "</div>";
  27. print "</div>";
  28. //return;
  29. }
  30. function pubOPMLUrl() {
  31. $url_path = Opml::opml_publish_url();
  32. print __("Your Public OPML URL is:");
  33. print "<div class=\"tagCloudContainer\">";
  34. print "<a id='pub_opml_url' href='$url_path' target='_blank'>$url_path</a>";
  35. print "</div>";
  36. print "<div align='center'>";
  37. print "<button dojoType=\"dijit.form.Button\" onclick=\"return opmlRegenKey()\">".
  38. __('Generate new URL')."</button> ";
  39. print "<button dojoType=\"dijit.form.Button\" onclick=\"return closeInfoBox()\">".
  40. __('Close this window')."</button>";
  41. print "</div>";
  42. //return;
  43. }
  44. function explainError() {
  45. print "<div class=\"errorExplained\">";
  46. if ($this->param == 1) {
  47. 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.");
  48. $stamp = (int) file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp");
  49. print "<p>" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp);
  50. }
  51. if ($this->param == 3) {
  52. 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.");
  53. $stamp = (int) file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp");
  54. print "<p>" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp);
  55. }
  56. print "</div>";
  57. print "<div align='center'>";
  58. print "<button onclick=\"return closeInfoBox()\">".
  59. __('Close this window')."</button>";
  60. print "</div>";
  61. //return;
  62. }
  63. function printTagCloud() {
  64. print "<div class=\"tagCloudContainer\">";
  65. // from here: http://www.roscripts.com/Create_tag_cloud-71.html
  66. $query = "SELECT tag_name, COUNT(post_int_id) AS count
  67. FROM ttrss_tags WHERE owner_uid = ".$_SESSION["uid"]."
  68. GROUP BY tag_name ORDER BY count DESC LIMIT 50";
  69. $result = $this->dbh->query($query);
  70. $tags = array();
  71. while ($line = $this->dbh->fetch_assoc($result)) {
  72. $tags[$line["tag_name"]] = $line["count"];
  73. }
  74. if(count($tags) == 0 ){ return; }
  75. ksort($tags);
  76. $max_size = 32; // max font size in pixels
  77. $min_size = 11; // min font size in pixels
  78. // largest and smallest array values
  79. $max_qty = max(array_values($tags));
  80. $min_qty = min(array_values($tags));
  81. // find the range of values
  82. $spread = $max_qty - $min_qty;
  83. if ($spread == 0) { // we don't want to divide by zero
  84. $spread = 1;
  85. }
  86. // set the font-size increment
  87. $step = ($max_size - $min_size) / ($spread);
  88. // loop through the tag array
  89. foreach ($tags as $key => $value) {
  90. // calculate font-size
  91. // find the $value in excess of $min_qty
  92. // multiply by the font-size increment ($size)
  93. // and add the $min_size set above
  94. $size = round($min_size + (($value - $min_qty) * $step));
  95. $key_escaped = str_replace("'", "\\'", $key);
  96. echo "<a href=\"javascript:viewfeed('$key_escaped') \" style=\"font-size: " .
  97. $size . "px\" title=\"$value articles tagged with " .
  98. $key . '">' . $key . '</a> ';
  99. }
  100. print "</div>";
  101. print "<div align='center'>";
  102. print "<button dojoType=\"dijit.form.Button\"
  103. onclick=\"return closeInfoBox()\">".
  104. __('Close this window')."</button>";
  105. print "</div>";
  106. }
  107. function printTagSelect() {
  108. print __("Match:"). "&nbsp;" .
  109. "<input class=\"noborder\" dojoType=\"dijit.form.RadioButton\" type=\"radio\" checked value=\"any\" name=\"tag_mode\" id=\"tag_mode_any\">";
  110. print "<label for=\"tag_mode_any\">".__("Any")."</label>";
  111. print "&nbsp;";
  112. print "<input class=\"noborder\" dojoType=\"dijit.form.RadioButton\" type=\"radio\" value=\"all\" name=\"tag_mode\" id=\"tag_mode_all\">";
  113. print "<label for=\"tag_mode_all\">".__("All tags.")."</input>";
  114. print "<select id=\"all_tags\" name=\"all_tags\" title=\"" . __('Which Tags?') . "\" multiple=\"multiple\" size=\"10\" style=\"width : 100%\">";
  115. $result = $this->dbh->query("SELECT DISTINCT tag_name FROM ttrss_tags WHERE owner_uid = ".$_SESSION['uid']."
  116. AND LENGTH(tag_name) <= 30 ORDER BY tag_name ASC");
  117. while ($row = $this->dbh->fetch_assoc($result)) {
  118. $tmp = htmlspecialchars($row["tag_name"]);
  119. print "<option value=\"$tmp\">$tmp</option>";
  120. }
  121. print "</select>";
  122. print "<div align='right'>";
  123. print "<button dojoType=\"dijit.form.Button\" onclick=\"viewfeed(get_all_tags($('all_tags')),
  124. get_radio_checked($('tag_mode')));\">" . __('Display entries') . "</button>";
  125. print "&nbsp;";
  126. print "<button dojoType=\"dijit.form.Button\"
  127. onclick=\"return closeInfoBox()\">" .
  128. __('Close this window') . "</button>";
  129. print "</div>";
  130. }
  131. function generatedFeed() {
  132. $this->params = explode(":", $this->param, 3);
  133. $feed_id = $this->dbh->escape_string($this->params[0]);
  134. $is_cat = (bool) $this->params[1];
  135. $key = get_feed_access_key($feed_id, $is_cat);
  136. $url_path = htmlspecialchars($this->params[2]) . "&key=" . $key;
  137. print "<h2>".__("You can view this feed as RSS using the following URL:")."</h2>";
  138. print "<div class=\"tagCloudContainer\">";
  139. print "<a id='gen_feed_url' href='$url_path' target='_blank'>$url_path</a>";
  140. print "</div>";
  141. print "<div align='center'>";
  142. print "<button dojoType=\"dijit.form.Button\" onclick=\"return genUrlChangeKey('$feed_id', '$is_cat')\">".
  143. __('Generate new URL')."</button> ";
  144. print "<button dojoType=\"dijit.form.Button\" onclick=\"return closeInfoBox()\">".
  145. __('Close this window')."</button>";
  146. print "</div>";
  147. //return;
  148. }
  149. }
  150. ?>