]>
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
= db_escape_string ( $this -> link
, $_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 \" >" ;
19 $owner_uid = $_SESSION [ "uid" ];
21 db_query ( $this -> link
, "BEGIN" );
23 print "<ul class='nomarks'>" ;
25 $opml = new Opml ( $this -> link
, $_REQUEST );
27 $opml -> opml_import ( $_SESSION [ "uid" ]);
29 db_query ( $this -> link
, "COMMIT" );
34 print "<div align='center'>" ;
35 print "<button dojoType= \" dijit.form.Button \"
36 onclick= \" dijit.byId('opmlImportDlg').execute() \" >" .
37 __ ( 'Close this window' ). "</button>" ;
45 function editPrefProfiles () {
46 print "<div dojoType= \" dijit.Toolbar \" >" ;
48 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
49 "<span>" . __ ( 'Select' ). "</span>" ;
50 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
51 print "<div onclick= \" selectTableRows('prefFeedProfileList', 'all') \"
52 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
53 print "<div onclick= \" selectTableRows('prefFeedProfileList', 'none') \"
54 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
57 print "<div style= \" float : right \" >" ;
59 print "<input name= \" newprofile \" dojoType= \" dijit.form.ValidationTextBox \"
61 <button dojoType= \" dijit.form.Button \"
62 onclick= \" dijit.byId('profileEditDlg').addProfile() \" >" .
63 __ ( 'Create profile' ). "</button></div>" ;
67 $result = db_query ( $this -> link
, "SELECT title,id FROM ttrss_settings_profiles
68 WHERE owner_uid = " . $_SESSION [ "uid" ]. " ORDER BY title" );
70 print "<div class= \" prefProfileHolder \" >" ;
72 print "<form id= \" profile_edit_form \" onsubmit= \" return false \" >" ;
74 print "<table width= \" 100% \" class= \" prefFeedProfileList \"
75 cellspacing= \" 0 \" id= \" prefFeedProfileList \" >" ;
77 print "<tr class= \" placeholder \" id= \" FCATR-0 \" >" ; #odd
79 print "<td width='5%' align='center'><input
81 onclick='toggleSelectRow2(this);'
82 dojoType= \" dijit.form.CheckBox \"
83 type= \" checkbox \" ></td>" ;
85 if (! $_SESSION [ "profile" ]) {
86 $is_active = __ ( "(active)" );
92 __ ( "Default profile" ) . " $is_active </span></td>" ;
98 while ( $line = db_fetch_assoc ( $result )) {
100 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
102 $profile_id = $line [ "id" ];
103 $this_row_id = "id= \" FCATR- $profile_id\" " ;
105 print "<tr class= \" placeholder \" $this_row_id >" ;
107 $edit_title = htmlspecialchars ( $line [ "title" ]);
109 print "<td width='5%' align='center'><input
110 onclick='toggleSelectRow2(this);'
111 id='FCATC- $profile_id '
112 dojoType= \" dijit.form.CheckBox \"
113 type= \" checkbox \" ></td>" ;
115 if ( $_SESSION [ "profile" ] == $line [ "id" ]) {
116 $is_active = __ ( "(active)" );
121 print "<td><span dojoType= \" dijit.InlineEditBox \"
122 width= \" 300px \" autoSave= \" false \"
123 profile-id= \" $profile_id\" >" . $edit_title .
124 "<script type= \" dojo/method \" event= \" onChange \" args= \" item \" >
128 content: {op: 'rpc', method: 'saveprofile',
130 id: this.srcNodeRef.getAttribute('profile-id')},
131 load: function(response) {
132 elem.attr('value', response);
136 </span> $is_active </td>" ;
147 print "<div class='dlgButtons'>
148 <div style='float : left'>
149 <button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('profileEditDlg').removeSelected() \" >" .
150 __ ( 'Remove selected profiles' ). "</button>
151 <button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('profileEditDlg').activateProfile() \" >" .
152 __ ( 'Activate profile' ). "</button>
155 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('profileEditDlg').hide() \" >" .
156 __ ( 'Close this window' ). "</button>" ;
161 function pubOPMLUrl () {
162 $url_path = Opml
:: opml_publish_url ( $this -> link
);
164 print __ ( "Your Public OPML URL is:" );
166 print "<div class= \" tagCloudContainer \" >" ;
167 print "<a id='pub_opml_url' href=' $url_path ' target='_blank'> $url_path </a>" ;
170 print "<div align='center'>" ;
172 print "<button dojoType= \" dijit.form.Button \" onclick= \" return opmlRegenKey() \" >" .
173 __ ( 'Generate new URL' ). "</button> " ;
175 print "<button dojoType= \" dijit.form.Button \" onclick= \" return closeInfoBox() \" >" .
176 __ ( 'Close this window' ). "</button>" ;
183 function explainError () {
184 print "<div class= \" errorExplained \" >" ;
186 if ( $this -> param
== 1 ) {
187 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." );
189 $stamp = ( int ) file_get_contents ( LOCK_DIRECTORY
. "/update_daemon.stamp" );
191 print "<p>" . __ ( "Last update:" ) . " " . date ( "Y.m.d, G:i" , $stamp );
195 if ( $this -> param
== 3 ) {
196 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." );
198 $stamp = ( int ) file_get_contents ( LOCK_DIRECTORY
. "/update_daemon.stamp" );
200 print "<p>" . __ ( "Last update:" ) . " " . date ( "Y.m.d, G:i" , $stamp );
206 print "<div align='center'>" ;
208 print "<button onclick= \" return closeInfoBox() \" >" .
209 __ ( 'Close this window' ). "</button>" ;
216 function printTagCloud () {
217 print "<div class= \" tagCloudContainer \" >" ;
219 // from here: http://www.roscripts.com/Create_tag_cloud-71.html
221 $query = "SELECT tag_name, COUNT(post_int_id) AS count
222 FROM ttrss_tags WHERE owner_uid = " . $_SESSION [ "uid" ]. "
223 GROUP BY tag_name ORDER BY count DESC LIMIT 50" ;
225 $result = db_query ( $this -> link
, $query );
229 while ( $line = db_fetch_assoc ( $result )) {
230 $tags [ $line [ "tag_name" ]] = $line [ "count" ];
233 if ( count ( $tags ) == 0 ){ return ; }
237 $max_size = 32 ; // max font size in pixels
238 $min_size = 11 ; // min font size in pixels
240 // largest and smallest array values
241 $max_qty = max ( array_values ( $tags ));
242 $min_qty = min ( array_values ( $tags ));
244 // find the range of values
245 $spread = $max_qty - $min_qty ;
246 if ( $spread == 0 ) { // we don't want to divide by zero
250 // set the font-size increment
251 $step = ( $max_size - $min_size ) / ( $spread );
253 // loop through the tag array
254 foreach ( $tags as $key => $value ) {
255 // calculate font-size
256 // find the $value in excess of $min_qty
257 // multiply by the font-size increment ($size)
258 // and add the $min_size set above
259 $size = round ( $min_size +
(( $value - $min_qty ) * $step ));
261 $key_escaped = str_replace ( "'" , " \\ '" , $key );
263 echo "<a href= \" javascript:viewfeed(' $key_escaped ') \" style= \" font-size: " .
264 $size . "px \" title= \" $value articles tagged with " .
265 $key . '">' . $key . '</a> ' ;
272 print "<div align='center'>" ;
273 print "<button dojoType= \" dijit.form.Button \"
274 onclick= \" return closeInfoBox() \" >" .
275 __ ( 'Close this window' ). "</button>" ;
280 function printTagSelect () {
282 print __ ( "Match:" ). " " .
283 "<input class= \" noborder \" dojoType= \" dijit.form.RadioButton \" type= \" radio \" checked value= \" any \" name= \" tag_mode \" id= \" tag_mode_any \" >" ;
284 print "<label for= \" tag_mode_any \" >" . __ ( "Any" ). "</label>" ;
286 print "<input class= \" noborder \" dojoType= \" dijit.form.RadioButton \" type= \" radio \" value= \" all \" name= \" tag_mode \" id= \" tag_mode_all \" >" ;
287 print "<label for= \" tag_mode_all \" >" . __ ( "All tags." ). "</input>" ;
289 print "<select id= \" all_tags \" name= \" all_tags \" title= \" " . __ ( 'Which Tags?' ) . " \" multiple= \" multiple \" size= \" 10 \" style= \" width : 100% \" >" ;
290 $result = db_query ( $this -> link
, "SELECT DISTINCT tag_name FROM ttrss_tags WHERE owner_uid = " . $_SESSION [ 'uid' ]. "
291 AND LENGTH(tag_name) <= 30 ORDER BY tag_name ASC" );
293 while ( $row = db_fetch_assoc ( $result )) {
294 $tmp = htmlspecialchars ( $row [ "tag_name" ]);
295 print "<option value= \" " . str_replace ( " " , " %20 " , $tmp ) . " \" > $tmp </option>" ;
300 print "<div align='right'>" ;
301 print "<button dojoType= \" dijit.form.Button \" onclick= \" viewfeed(get_all_tags($('all_tags')),
302 get_radio_checked($('tag_mode'))); \" >" . __ ( 'Display entries' ) . "</button>" ;
304 print "<button dojoType= \" dijit.form.Button \"
305 onclick= \" return closeInfoBox() \" >" .
306 __ ( 'Close this window' ) . "</button>" ;
311 function generatedFeed () {
313 $this -> params
= explode ( ":" , $this -> param
, 3 );
314 $feed_id = db_escape_string ( $this -> link
, $this -> params
[ 0 ]);
315 $is_cat = ( bool ) $this -> params
[ 1 ];
317 $key = get_feed_access_key ( $this -> link
, $feed_id , $is_cat );
319 $url_path = htmlspecialchars ( $this -> params
[ 2 ]) . "&key=" . $key ;
321 print "<h2>" . __ ( "You can view this feed as RSS using the following URL:" ). "</h2>" ;
323 print "<div class= \" tagCloudContainer \" >" ;
324 print "<a id='gen_feed_url' href=' $url_path ' target='_blank'> $url_path </a>" ;
327 print "<div align='center'>" ;
329 print "<button dojoType= \" dijit.form.Button \" onclick= \" return genUrlChangeKey(' $feed_id ', ' $is_cat ') \" >" .
330 __ ( 'Generate new URL' ). "</button> " ;
332 print "<button dojoType= \" dijit.form.Button \" onclick= \" return closeInfoBox() \" >" .
333 __ ( 'Close this window' ). "</button>" ;
340 function newVersion () {
342 $version_data = check_for_update ( $this -> link
);
343 $version = $version_data [ 'version' ];
344 $id = $version_data [ 'version_id' ];
346 if ( $version && $id ) {
347 print "<div class='tagCloudContainer'>" ;
349 print T_sprintf ( "New version of Tiny Tiny RSS is available ( %s )." ,
354 $details = "http://tt-rss.org/redmine/versions/ $id " ;
355 $download = "http://tt-rss.org/#Download" ;
357 print "<p align='center'>" . __ ( "You can update using built-in updater in the Preferences or by using update.php" ). "</p>" ;
359 print "<div style='text-align : center'>" ;
360 print "<button dojoType= \" dijit.form.Button \"
361 onclick= \" return window.open(' $details ') \" >" . __ ( "See the release notes" ). "</button>" ;
362 print "<button dojoType= \" dijit.form.Button \"
363 onclick= \" return window.open(' $download ') \" >" . __ ( "Download" ). "</button>" ;
364 print "<button dojoType= \" dijit.form.Button \"
365 onclick= \" return dijit.byId('newVersionDlg').hide() \" >" .
366 __ ( 'Close this window' ). "</button>" ;
369 print "<div class='tagCloudContainer'>" ;
371 print "<p align='center'>" . __ ( "Error receiving version information or no new version available." ). "</p>" ;
375 print "<div style='text-align : center'>" ;
376 print "<button dojoType= \" dijit.form.Button \"
377 onclick= \" return dijit.byId('newVersionDlg').hide() \" >" .
378 __ ( 'Close this window' ). "</button>" ;
386 function customizeCSS () {
387 $value = get_pref ( $this -> link
, "USER_STYLESHEET" );
389 $value = str_replace ( "<br/>" , " \n " , $value );
391 print_notice ( T_sprintf ( "You can override colors, fonts and layout of your currently selected theme with custom CSS declarations here. <a target= \" _blank \" class= \" visibleLink \" href= \" %s\" >This file</a> can be used as a baseline." , "tt-rss.css" ));
393 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" rpc \" >" ;
394 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" setpref \" >" ;
395 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" key \" value= \" USER_STYLESHEET \" >" ;
397 print "<table width='100%'><tr><td>" ;
398 print "<textarea dojoType= \" dijit.form.SimpleTextarea \"
399 style='font-size : 12px; width : 100%; height: 200px;'
400 placeHolder='body#ttrssMain { font-size : 14px; };'
401 name='value'> $value </textarea>" ;
402 print "</td></tr></table>" ;
404 print "<div class='dlgButtons'>" ;
405 print "<button dojoType= \" dijit.form.Button \"
406 onclick= \" dijit.byId('cssEditDlg').execute() \" >" . __ ( 'Save' ). "</button> " ;
407 print "<button dojoType= \" dijit.form.Button \"
408 onclick= \" dijit.byId('cssEditDlg').hide() \" >" . __ ( 'Cancel' ). "</button>" ;
413 function addInstance () {
414 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-instances \" >" ;
415 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" add \" >" ;
417 print "<div class= \" dlgSec \" >" . __ ( "Instance" ). "</div>" ;
419 print "<div class= \" dlgSecCont \" >" ;
423 print __ ( "URL:" ) . " " ;
425 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
426 placeHolder= \" " . __ ( "Instance URL" ). " \"
427 regExp='^(http|https)://.*'
428 style= \" font-size : 16px; width: 20em \" name= \" access_url \" >" ;
432 $access_key = sha1 ( uniqid ( rand (), true ));
436 print __ ( "Access key:" ) . " " ;
438 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
439 placeHolder= \" " . __ ( "Access key" ). " \" regExp='\w{40}'
440 style= \" width: 20em \" name= \" access_key \" id= \" instance_add_key \"
441 value= \" $access_key\" >" ;
443 print "<p class='insensitive'>" . __ ( "Use one access key for both linked instances." );
447 print "<div class= \" dlgButtons \" >
448 <div style='float : left'>
449 <button dojoType= \" dijit.form.Button \"
450 onclick= \" return dijit.byId('instanceAddDlg').regenKey() \" >" .
451 __ ( 'Generate new key' ). "</button>
453 <button dojoType= \" dijit.form.Button \"
454 onclick= \" return dijit.byId('instanceAddDlg').execute() \" >" .
455 __ ( 'Create link' ). "</button>
456 <button dojoType= \" dijit.form.Button \"
457 onclick= \" return dijit.byId('instanceAddDlg').hide() \"\" >" .
458 __ ( 'Cancel' ). "</button></div>" ;
463 function batchSubscribe () {
464 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" rpc \" >" ;
465 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" batchaddfeeds \" >" ;
467 print "<table width='100%'><tr><td>
468 " . __ ( "Add one valid RSS feed per line (no feed detection is done)" ). "
469 </td><td align='right'>" ;
470 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
471 print __ ( 'Place in category:' ) . " " ;
472 print_feed_cat_select ( $this -> link
, "cat" , false , 'dojoType="dijit.form.Select"' );
474 print "</td></tr><tr><td colspan='2'>" ;
476 style='font-size : 12px; width : 100%; height: 200px;'
477 placeHolder= \" " . __ ( "Feeds to subscribe, One per line" ). " \"
478 dojoType= \" dijit.form.SimpleTextarea \" required= \" 1 \" name= \" feeds \" ></textarea>" ;
480 print "</td></tr><tr><td colspan='2'>" ;
482 print "<div id='feedDlg_loginContainer' style='display : none'>
484 " <input dojoType= \" dijit.form.TextBox \" name='login' \"
485 placeHolder= \" " . __ ( "Login" ). " \"
486 style= \" width : 10em; \" > " .
488 placeHolder= \" " . __ ( "Password" ). " \"
489 dojoType= \" dijit.form.TextBox \" type='password'
490 style= \" width : 10em; \" name='pass' \" >" .
493 print "</td></tr><tr><td colspan='2'>" ;
495 print "<div style= \" clear : both \" >
496 <input type= \" checkbox \" name= \" need_auth \" dojoType= \" dijit.form.CheckBox \" id= \" feedDlg_loginCheck \"
497 onclick='checkboxToggleElement(this, \" feedDlg_loginContainer \" )'>
498 <label for= \" feedDlg_loginCheck \" >" .
499 __ ( 'Feeds require authentication.' ). "</div>" ;
503 print "</td></tr></table>" ;
505 print "<div class= \" dlgButtons \" >
506 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('batchSubDlg').execute() \" >" . __ ( 'Subscribe' ). "</button>
507 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('batchSubDlg').hide() \" >" . __ ( 'Cancel' ). "</button>