dlg.php 6.3 KB

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