]> git.wh0rd.org - tt-rss.git/blame - classes/dlg.php
dlg: PDO
[tt-rss.git] / classes / dlg.php
CommitLineData
3f363052 1<?php
9da07c8a 2class Dlg extends Handler_Protected {
3f363052 3 private $param;
415a3b50 4 private $params;
46da73c2 5
415a3b50 6 function before($method) {
17f9d200 7 if (parent::before($method)) {
fb54e3b1
AD
8 header("Content-Type: text/html"); # required for iframe
9
9ead64f6 10 $this->param = $_REQUEST["param"];
3f363052
AD
11 return true;
12 }
13 return false;
14 }
46da73c2 15
3f363052 16 function importOpml() {
34aa9e20
AD
17 print __("If you have imported labels and/or filters, you might need to reload preferences to see your new data.") . "</p>";
18
3f363052 19 print "<div class=\"prefFeedOPMLHolder\">";
3f363052 20
9ead64f6 21 $this->pdo->beginTransaction();
3f363052 22
d75409bf 23 print "<ul class='nomarks'>";
3f363052 24
a42c55f0 25 $opml = new Opml($_REQUEST);
3f363052 26
d75409bf 27 $opml->opml_import($_SESSION["uid"]);
3f363052 28
9ead64f6 29 $this->pdo->commit();
b77d0c4a 30
c4c74732 31 print "</ul>";
3f363052
AD
32 print "</div>";
33
34 print "<div align='center'>";
35 print "<button dojoType=\"dijit.form.Button\"
34aa9e20 36 onclick=\"dijit.byId('opmlImportDlg').execute()\">".
3f363052
AD
37 __('Close this window')."</button>";
38 print "</div>";
39
40 print "</div>";
41
42 //return;
43 }
44
3f363052 45 function pubOPMLUrl() {
6322ac79 46 $url_path = Opml::opml_publish_url();
3f363052
AD
47
48 print __("Your Public OPML URL is:");
49
50 print "<div class=\"tagCloudContainer\">";
51 print "<a id='pub_opml_url' href='$url_path' target='_blank'>$url_path</a>";
52 print "</div>";
53
54 print "<div align='center'>";
55
56 print "<button dojoType=\"dijit.form.Button\" onclick=\"return opmlRegenKey()\">".
57 __('Generate new URL')."</button> ";
58
59 print "<button dojoType=\"dijit.form.Button\" onclick=\"return closeInfoBox()\">".
60 __('Close this window')."</button>";
61
62 print "</div>";
3f363052
AD
63
64 //return;
65 }
66
67 function explainError() {
3f363052
AD
68 print "<div class=\"errorExplained\">";
69
70 if ($this->param == 1) {
71 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.");
72
73 $stamp = (int) file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp");
74
75 print "<p>" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp);
76
77 }
78
79 if ($this->param == 3) {
80 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.");
81
82 $stamp = (int) file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp");
83
84 print "<p>" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp);
85
86 }
87
88 print "</div>";
89
90 print "<div align='center'>";
91
92 print "<button onclick=\"return closeInfoBox()\">".
93 __('Close this window')."</button>";
94
95 print "</div>";
3f363052
AD
96
97 //return;
98 }
3f363052
AD
99
100 function printTagCloud() {
3f363052
AD
101 print "<div class=\"tagCloudContainer\">";
102
79178062
AD
103 // from here: http://www.roscripts.com/Create_tag_cloud-71.html
104
9ead64f6
AD
105 $sth = $this->pdo->prepare("SELECT tag_name, COUNT(post_int_id) AS count
106 FROM ttrss_tags WHERE owner_uid = ?
107 GROUP BY tag_name ORDER BY count DESC LIMIT 50");
108 $sth->execute([$_SESSION['uid']]);
79178062
AD
109
110 $tags = array();
111
9ead64f6 112 while ($line = $sth->fetch()) {
79178062
AD
113 $tags[$line["tag_name"]] = $line["count"];
114 }
115
a42c55f0 116 if(count($tags) == 0 ){ return; }
79178062
AD
117
118 ksort($tags);
119
120 $max_size = 32; // max font size in pixels
121 $min_size = 11; // min font size in pixels
122
123 // largest and smallest array values
124 $max_qty = max(array_values($tags));
125 $min_qty = min(array_values($tags));
126
127 // find the range of values
128 $spread = $max_qty - $min_qty;
129 if ($spread == 0) { // we don't want to divide by zero
130 $spread = 1;
131 }
132
133 // set the font-size increment
134 $step = ($max_size - $min_size) / ($spread);
135
136 // loop through the tag array
137 foreach ($tags as $key => $value) {
138 // calculate font-size
139 // find the $value in excess of $min_qty
140 // multiply by the font-size increment ($size)
141 // and add the $min_size set above
142 $size = round($min_size + (($value - $min_qty) * $step));
143
144 $key_escaped = str_replace("'", "\\'", $key);
145
dcbe36b2 146 echo "<a href=\"javascript:viewfeed({feed:'$key_escaped'}) \" style=\"font-size: " .
79178062
AD
147 $size . "px\" title=\"$value articles tagged with " .
148 $key . '">' . $key . '</a> ';
149 }
150
151
3f363052
AD
152
153 print "</div>";
154
155 print "<div align='center'>";
156 print "<button dojoType=\"dijit.form.Button\"
157 onclick=\"return closeInfoBox()\">".
158 __('Close this window')."</button>";
159 print "</div>";
160
3f363052
AD
161 }
162
3f363052 163 function generatedFeed() {
46da73c2 164
3f363052 165 $this->params = explode(":", $this->param, 3);
9ead64f6 166 $feed_id = $this->params[0];
3f363052
AD
167 $is_cat = (bool) $this->params[1];
168
a42c55f0 169 $key = get_feed_access_key($feed_id, $is_cat);
3f363052
AD
170
171 $url_path = htmlspecialchars($this->params[2]) . "&key=" . $key;
172
fcef9eea 173 print "<h2>".__("You can view this feed as RSS using the following URL:")."</h2>";
3f363052
AD
174
175 print "<div class=\"tagCloudContainer\">";
176 print "<a id='gen_feed_url' href='$url_path' target='_blank'>$url_path</a>";
177 print "</div>";
178
179 print "<div align='center'>";
180
181 print "<button dojoType=\"dijit.form.Button\" onclick=\"return genUrlChangeKey('$feed_id', '$is_cat')\">".
182 __('Generate new URL')."</button> ";
183
184 print "<button dojoType=\"dijit.form.Button\" onclick=\"return closeInfoBox()\">".
185 __('Close this window')."</button>";
186
187 print "</div>";
3f363052
AD
188
189 //return;
190 }
191
ea79a0e0 192}