]>
git.wh0rd.org - tt-rss.git/blob - classes/dlg.php
2 class Dlg
extends Handler_Protected
{
5 function before ( $method ) {
6 if ( parent
:: before ( $method )) {
7 header ( "Content-Type: text/html" ); # required for iframe
9 $this -> param
= $this -> dbh
-> escape_string ( $_REQUEST [ "param" ]);
15 function importOpml () {
16 print __ ( "If you have imported labels and/or filters, you might need to reload preferences to see your new data." ) . "</p>" ;
18 print "<div class= \" prefFeedOPMLHolder \" >" ;
20 $this -> dbh
-> query ( "BEGIN" );
22 print "<ul class='nomarks'>" ;
24 $opml = new Opml ( $_REQUEST );
26 $opml -> opml_import ( $_SESSION [ "uid" ]);
28 $this -> dbh
-> query ( "COMMIT" );
33 print "<div align='center'>" ;
34 print "<button dojoType= \" dijit.form.Button \"
35 onclick= \" dijit.byId('opmlImportDlg').execute() \" >" .
36 __ ( 'Close this window' ). "</button>" ;
44 function pubOPMLUrl () {
45 $url_path = Opml
:: opml_publish_url ();
47 print __ ( "Your Public OPML URL is:" );
49 print "<div class= \" tagCloudContainer \" >" ;
50 print "<a id='pub_opml_url' href=' $url_path ' target='_blank'> $url_path </a>" ;
53 print "<div align='center'>" ;
55 print "<button dojoType= \" dijit.form.Button \" onclick= \" return opmlRegenKey() \" >" .
56 __ ( 'Generate new URL' ). "</button> " ;
58 print "<button dojoType= \" dijit.form.Button \" onclick= \" return closeInfoBox() \" >" .
59 __ ( 'Close this window' ). "</button>" ;
66 function explainError () {
67 print "<div class= \" errorExplained \" >" ;
69 if ( $this -> param
== 1 ) {
70 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 $stamp = ( int ) file_get_contents ( LOCK_DIRECTORY
. "/update_daemon.stamp" );
74 print "<p>" . __ ( "Last update:" ) . " " . date ( "Y.m.d, G:i" , $stamp );
78 if ( $this -> param
== 3 ) {
79 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 $stamp = ( int ) file_get_contents ( LOCK_DIRECTORY
. "/update_daemon.stamp" );
83 print "<p>" . __ ( "Last update:" ) . " " . date ( "Y.m.d, G:i" , $stamp );
89 print "<div align='center'>" ;
91 print "<button onclick= \" return closeInfoBox() \" >" .
92 __ ( 'Close this window' ). "</button>" ;
99 function printTagCloud () {
100 print "<div class= \" tagCloudContainer \" >" ;
102 // from here: http://www.roscripts.com/Create_tag_cloud-71.html
104 $query = "SELECT tag_name, COUNT(post_int_id) AS count
105 FROM ttrss_tags WHERE owner_uid = " . $_SESSION [ "uid" ]. "
106 GROUP BY tag_name ORDER BY count DESC LIMIT 50" ;
108 $result = $this -> dbh
-> query ( $query );
112 while ( $line = $this -> dbh
-> fetch_assoc ( $result )) {
113 $tags [ $line [ "tag_name" ]] = $line [ "count" ];
116 if ( count ( $tags ) == 0 ){ return ; }
120 $max_size = 32 ; // max font size in pixels
121 $min_size = 11 ; // min font size in pixels
123 // largest and smallest array values
124 $max_qty = max ( array_values ( $tags ));
125 $min_qty = min ( array_values ( $tags ));
127 // find the range of values
128 $spread = $max_qty - $min_qty ;
129 if ( $spread == 0 ) { // we don't want to divide by zero
133 // set the font-size increment
134 $step = ( $max_size - $min_size ) / ( $spread );
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 ));
144 $key_escaped = str_replace ( "'" , " \\ '" , $key );
146 echo "<a href= \" javascript:viewfeed(' $key_escaped ') \" style= \" font-size: " .
147 $size . "px \" title= \" $value articles tagged with " .
148 $key . '">' . $key . '</a> ' ;
155 print "<div align='center'>" ;
156 print "<button dojoType= \" dijit.form.Button \"
157 onclick= \" return closeInfoBox() \" >" .
158 __ ( 'Close this window' ). "</button>" ;
163 function printTagSelect () {
165 print __ ( "Match:" ). " " .
166 "<input class= \" noborder \" dojoType= \" dijit.form.RadioButton \" type= \" radio \" checked value= \" any \" name= \" tag_mode \" id= \" tag_mode_any \" >" ;
167 print "<label for= \" tag_mode_any \" >" . __ ( "Any" ). "</label>" ;
169 print "<input class= \" noborder \" dojoType= \" dijit.form.RadioButton \" type= \" radio \" value= \" all \" name= \" tag_mode \" id= \" tag_mode_all \" >" ;
170 print "<label for= \" tag_mode_all \" >" . __ ( "All tags." ). "</input>" ;
172 print "<select id= \" all_tags \" name= \" all_tags \" title= \" " . __ ( 'Which Tags?' ) . " \" multiple= \" multiple \" size= \" 10 \" style= \" width : 100% \" >" ;
173 $result = $this -> dbh
-> query ( "SELECT DISTINCT tag_name FROM ttrss_tags WHERE owner_uid = " . $_SESSION [ 'uid' ]. "
174 AND LENGTH(tag_name) <= 30 ORDER BY tag_name ASC" );
176 while ( $row = $this -> dbh
-> fetch_assoc ( $result )) {
177 $tmp = htmlspecialchars ( $row [ "tag_name" ]);
178 print "<option value= \" $tmp\" > $tmp </option>" ;
183 print "<div align='right'>" ;
184 print "<button dojoType= \" dijit.form.Button \" onclick= \" viewfeed(get_all_tags($('all_tags')),
185 get_radio_checked($('tag_mode'))); \" >" . __ ( 'Display entries' ) . "</button>" ;
187 print "<button dojoType= \" dijit.form.Button \"
188 onclick= \" return closeInfoBox() \" >" .
189 __ ( 'Close this window' ) . "</button>" ;
194 function generatedFeed () {
196 $this -> params
= explode ( ":" , $this -> param
, 3 );
197 $feed_id = $this -> dbh
-> escape_string ( $this -> params
[ 0 ]);
198 $is_cat = ( bool ) $this -> params
[ 1 ];
200 $key = get_feed_access_key ( $feed_id , $is_cat );
202 $url_path = htmlspecialchars ( $this -> params
[ 2 ]) . "&key=" . $key ;
204 print "<h2>" . __ ( "You can view this feed as RSS using the following URL:" ). "</h2>" ;
206 print "<div class= \" tagCloudContainer \" >" ;
207 print "<a id='gen_feed_url' href=' $url_path ' target='_blank'> $url_path </a>" ;
210 print "<div align='center'>" ;
212 print "<button dojoType= \" dijit.form.Button \" onclick= \" return genUrlChangeKey(' $feed_id ', ' $is_cat ') \" >" .
213 __ ( 'Generate new URL' ). "</button> " ;
215 print "<button dojoType= \" dijit.form.Button \" onclick= \" return closeInfoBox() \" >" .
216 __ ( 'Close this window' ). "</button>" ;
223 function newVersion () {
225 $version_data = check_for_update ();
226 $version = $version_data [ 'version' ];
227 $id = $version_data [ 'version_id' ];
229 if ( $version && $id ) {
230 print "<div class='tagCloudContainer'>" ;
232 print T_sprintf ( "New version of Tiny Tiny RSS is available ( %s )." ,
237 $details = "http://tt-rss.org/redmine/versions/ $id " ;
238 $download = "http://tt-rss.org/#Download" ;
240 print "<p align='center'>" . __ ( "You can update using built-in updater in the Preferences or by using update.php" ). "</p>" ;
242 print "<div style='text-align : center'>" ;
243 print "<button dojoType= \" dijit.form.Button \"
244 onclick= \" return window.open(' $details ') \" >" . __ ( "See the release notes" ). "</button>" ;
245 print "<button dojoType= \" dijit.form.Button \"
246 onclick= \" return window.open(' $download ') \" >" . __ ( "Download" ). "</button>" ;
247 print "<button dojoType= \" dijit.form.Button \"
248 onclick= \" return dijit.byId('newVersionDlg').hide() \" >" .
249 __ ( 'Close this window' ). "</button>" ;
252 print "<div class='tagCloudContainer'>" ;
254 print "<p align='center'>" . __ ( "Error receiving version information or no new version available." ). "</p>" ;
258 print "<div style='text-align : center'>" ;
259 print "<button dojoType= \" dijit.form.Button \"
260 onclick= \" return dijit.byId('newVersionDlg').hide() \" >" .
261 __ ( 'Close this window' ). "</button>" ;