]>
Commit | Line | Data |
---|---|---|
1 | <?php | |
2 | class Dlg extends Handler_Protected { | |
3 | private $param; | |
4 | private $params; | |
5 | ||
6 | function before($method) { | |
7 | if (parent::before($method)) { | |
8 | header("Content-Type: text/html"); # required for iframe | |
9 | ||
10 | $this->param = $this->dbh->escape_string($_REQUEST["param"]); | |
11 | return true; | |
12 | } | |
13 | return false; | |
14 | } | |
15 | ||
16 | function importOpml() { | |
17 | print __("If you have imported labels and/or filters, you might need to reload preferences to see your new data.") . "</p>"; | |
18 | ||
19 | print "<div class=\"prefFeedOPMLHolder\">"; | |
20 | ||
21 | $this->dbh->query("BEGIN"); | |
22 | ||
23 | print "<ul class='nomarks'>"; | |
24 | ||
25 | $opml = new Opml($_REQUEST); | |
26 | ||
27 | $opml->opml_import($_SESSION["uid"]); | |
28 | ||
29 | $this->dbh->query("COMMIT"); | |
30 | ||
31 | print "</ul>"; | |
32 | print "</div>"; | |
33 | ||
34 | print "<div align='center'>"; | |
35 | print "<button dojoType=\"dijit.form.Button\" | |
36 | onclick=\"dijit.byId('opmlImportDlg').execute()\">". | |
37 | __('Close this window')."</button>"; | |
38 | print "</div>"; | |
39 | ||
40 | print "</div>"; | |
41 | ||
42 | //return; | |
43 | } | |
44 | ||
45 | function pubOPMLUrl() { | |
46 | $url_path = Opml::opml_publish_url(); | |
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>"; | |
63 | ||
64 | //return; | |
65 | } | |
66 | ||
67 | function explainError() { | |
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>"; | |
96 | ||
97 | //return; | |
98 | } | |
99 | ||
100 | function printTagCloud() { | |
101 | print "<div class=\"tagCloudContainer\">"; | |
102 | ||
103 | // from here: http://www.roscripts.com/Create_tag_cloud-71.html | |
104 | ||
105 | $query = "SELECT tag_name, COUNT(post_int_id) AS count | |
106 | FROM ttrss_tags WHERE owner_uid = ".$_SESSION["uid"]." | |
107 | GROUP BY tag_name ORDER BY count DESC LIMIT 50"; | |
108 | ||
109 | $result = $this->dbh->query($query); | |
110 | ||
111 | $tags = array(); | |
112 | ||
113 | while ($line = $this->dbh->fetch_assoc($result)) { | |
114 | $tags[$line["tag_name"]] = $line["count"]; | |
115 | } | |
116 | ||
117 | if(count($tags) == 0 ){ return; } | |
118 | ||
119 | ksort($tags); | |
120 | ||
121 | $max_size = 32; // max font size in pixels | |
122 | $min_size = 11; // min font size in pixels | |
123 | ||
124 | // largest and smallest array values | |
125 | $max_qty = max(array_values($tags)); | |
126 | $min_qty = min(array_values($tags)); | |
127 | ||
128 | // find the range of values | |
129 | $spread = $max_qty - $min_qty; | |
130 | if ($spread == 0) { // we don't want to divide by zero | |
131 | $spread = 1; | |
132 | } | |
133 | ||
134 | // set the font-size increment | |
135 | $step = ($max_size - $min_size) / ($spread); | |
136 | ||
137 | // loop through the tag array | |
138 | foreach ($tags as $key => $value) { | |
139 | // calculate font-size | |
140 | // find the $value in excess of $min_qty | |
141 | // multiply by the font-size increment ($size) | |
142 | // and add the $min_size set above | |
143 | $size = round($min_size + (($value - $min_qty) * $step)); | |
144 | ||
145 | $key_escaped = str_replace("'", "\\'", $key); | |
146 | ||
147 | echo "<a href=\"javascript:viewfeed({feed:'$key_escaped'}) \" style=\"font-size: " . | |
148 | $size . "px\" title=\"$value articles tagged with " . | |
149 | $key . '">' . $key . '</a> '; | |
150 | } | |
151 | ||
152 | ||
153 | ||
154 | print "</div>"; | |
155 | ||
156 | print "<div align='center'>"; | |
157 | print "<button dojoType=\"dijit.form.Button\" | |
158 | onclick=\"return closeInfoBox()\">". | |
159 | __('Close this window')."</button>"; | |
160 | print "</div>"; | |
161 | ||
162 | } | |
163 | ||
164 | function generatedFeed() { | |
165 | ||
166 | $this->params = explode(":", $this->param, 3); | |
167 | $feed_id = $this->dbh->escape_string($this->params[0]); | |
168 | $is_cat = (bool) $this->params[1]; | |
169 | ||
170 | $key = get_feed_access_key($feed_id, $is_cat); | |
171 | ||
172 | $url_path = htmlspecialchars($this->params[2]) . "&key=" . $key; | |
173 | ||
174 | print "<h2>".__("You can view this feed as RSS using the following URL:")."</h2>"; | |
175 | ||
176 | print "<div class=\"tagCloudContainer\">"; | |
177 | print "<a id='gen_feed_url' href='$url_path' target='_blank'>$url_path</a>"; | |
178 | print "</div>"; | |
179 | ||
180 | print "<div align='center'>"; | |
181 | ||
182 | print "<button dojoType=\"dijit.form.Button\" onclick=\"return genUrlChangeKey('$feed_id', '$is_cat')\">". | |
183 | __('Generate new URL')."</button> "; | |
184 | ||
185 | print "<button dojoType=\"dijit.form.Button\" onclick=\"return closeInfoBox()\">". | |
186 | __('Close this window')."</button>"; | |
187 | ||
188 | print "</div>"; | |
189 | ||
190 | //return; | |
191 | } | |
192 | ||
193 | } |