]> git.wh0rd.org - tt-rss.git/blobdiff - modules/popup-dialog.php
use Modalbox library for popup dialogs
[tt-rss.git] / modules / popup-dialog.php
index 4d68fb9712fa8c758d4a793188255cb91c01efb4..c018acbd84fb7f269b9a3d2c3ea3ef764f8ab8ca 100644 (file)
@@ -3,9 +3,11 @@
                $id = $_REQUEST["id"];
                $param = db_escape_string($_REQUEST["param"]);
 
+               print "<dlg id=\"$id\">";
+
                if ($id == "importOpml") {
-                       print "<div id=\"infoBoxTitle\">".__('OPML Import')."</div>";
-                       print "<div class=\"infoBoxContents\">";
+                       print "<title>".__('OPML Import')."</title>";
+                       print "<content><![CDATA[";
 
                        print "<div class=\"prefFeedCatHolder\">";
 
                        print "parent.opmlImportHandler(this)";
                        print "</script>";
 
-                       print "</div></div>";
+                       print "</div>";
+                       print "]]></content>";
 
-                       return;
+                       //return;
                }
 
                if ($id == "editPrefProfiles") {
 
-                       print "<div id=\"infoBoxTitle\">".__('Settings Profiles')."</div>";
-                       print "<div class=\"infoBoxContents\">";
+                       print "<title>".__('Settings Profiles')."</title>";
+                       print "<content><![CDATA[";
 
                        print "<div><input id=\"fadd_profile\" 
                                        onkeypress=\"return filterCR(event, addPrefProfile)\"
@@ -80,8 +83,8 @@
                                WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title");
 
                        print   __('Select:')." 
-                               <a href=\"javascript:selectPrefRows('fcat', true)\">".__('All')."</a>,
-                               <a href=\"javascript:selectPrefRows('fcat', false)\">".__('None')."</a>";
+                               <a href=\"#\" onclick=\"selectTableRows('prefFeedCatList', 'all')\">".__('All')."</a>,
+                               <a href=\"#\" onclick=\"selectTableRows('prefFeedCatList', 'none')\">".__('None')."</a>";
 
                        print "<div class=\"prefFeedCatHolder\">";
 
@@ -93,7 +96,7 @@
                        print "<tr class=\"odd\" id=\"FCATR-0\">";
 
                        print "<td width='5%' align='center'><input 
-                               onclick='toggleSelectPrefRow(this, \"fcat\");' 
+                               onclick='toggleSelectRow(this);' 
                                type=\"checkbox\" id=\"FCCHK-0\"></td>";
 
                        if (!$_SESSION["profile"]) {
                                $edit_title = htmlspecialchars($line["title"]);
        
                                print "<td width='5%' align='center'><input 
-                                       onclick='toggleSelectPrefRow(this, \"fcat\");' 
+                                       onclick='toggleSelectRow(this);' 
                                        type=\"checkbox\" id=\"FCCHK-$cat_id\"></td>";
 
                                if ($_SESSION["profile"] == $line["id"]) {
                        print "<button onclick=\"return closeInfoBox()\">".
                                __('Close this window')."</button>";
 
-                       print "</div></div>";
-
-                       return;
-               }
-
-               if ($id == "pubUrl") {
-
-                       print "<div id=\"infoBoxTitle\">".__('Published Articles')."</div>";
-                       print "<div class=\"infoBoxContents\">";
-       
-                       $url_path = article_publish_url($link);
-
-                       print __("Your Published articles feed URL is:");
-
-                       print "<div class=\"tagCloudContainer\">";
-                       print "<a id='pub_feed_url' href='$url_path' target='_blank'>$url_path</a>";
                        print "</div>";
+                       print "]]></content>";
 
-                       print "<div align='center'>";
-
-                       print "<button onclick=\"return pubRegenKey()\">".
-                               __('Generate new URL')."</button> ";
-
-                       print "<input class=\"button\"
-                               type=\"submit\" onclick=\"return closeInfoBox()\" 
-                               value=\"".__('Close this window')."\">";
-
-                       print "</div></div>";
-
-                       return;
+                       //return;
                }
 
                if ($id == "pubOPMLUrl") {
 
-                       print "<div id=\"infoBoxTitle\">".__('Public OPML URL')."</div>";
-                       print "<div class=\"infoBoxContents\">";
-       
+                       print "<title>".__('Public OPML URL')."</title>";
+                       print "<content><![CDATA[";
+
                        $url_path = opml_publish_url($link);
 
                        print __("Your Public OPML URL is:");
                        print "<button onclick=\"return opmlRegenKey()\">".
                                __('Generate new URL')."</button> ";
 
-                       print "<input class=\"button\"
-                               type=\"submit\" onclick=\"return closeInfoBox()\" 
-                               value=\"".__('Close this window')."\">";
+                       print "<button onclick=\"return closeInfoBox()\">".
+                               __('Close this window')."</button>";
 
-                       print "</div></div>";
+                       print "</div>";
+                       print "]]></content>";
 
-                       return;
+                       //return;
                }
 
                if ($id == "explainError") {
 
-                       print "<div id=\"infoBoxTitle\">".__('Notice')."</div>";
-                       print "<div class=\"infoBoxContents\">";
+                       print "<title>".__('Notice')."</title>";
+                       print "<content><![CDATA[";
 
                        print "<div class=\"errorExplained\">";
 
                        
                        print "<div align='center'>";
 
-                       print "<input class=\"button\"
-                               type=\"submit\" onclick=\"return closeInfoBox()\" 
-                               value=\"".__('Close this window')."\">";
+                       print "<button onclick=\"return closeInfoBox()\"".
+                               __('Close this window')."</button>";
 
-                       print "</div></div>";
+                       print "</div>";
+                       print "]]></content>";
 
-                       return;
+                       //return;
                }
 
                if ($id == "quickAddFeed") {
 
-                       print "<div id=\"infoBoxTitle\">".__('Subscribe to Feed')."</div>";
-                       print "<div class=\"infoBoxContents\">";
+                       print "<title>".__('Subscribe to Feed')."</title>";
+                       print "<content><![CDATA[";
 
                        print "<form id='feed_add_form' onsubmit='return false'>";
 
 
                        print "<input size=\"40\"
                                        onkeypress=\"return filterCR(event, subscribeToFeed)\"
-                                       name=\"feed\" id=\"feed_url\"></td></tr>";
+                                       name=\"feed\" id=\"feed_url\">";
 
                        print "<br/>";
 
 
                        print "</div>";
 
+                       print '<div id="fadd_feeds_container" style="display:none">
+
+                                       <div class="dlgSec">' . __('Available feeds') . '</div>
+                                       <div class="dlgSecCont">'
+
+                                       . ' <select name="feed" id="faad_feeds_container_select" size="3"></select>'
+                               . '</div></div>';
+
                        print "<div id='fadd_login_container' style='display:none'>
        
                                        <div class=\"dlgSec\">".__("Authentication")."</div>
                                        onclick=\"return subscribeToFeed()\">".__('Subscribe')."</button>
                                <button onclick=\"return displayDlg('feedBrowser')\">".__('More feeds')."</button>
                                <button onclick=\"return closeInfoBox()\">".__('Cancel')."</button></div>";
-                       
-                       return;
+
+                       print "]]></content>";
+
+                       //return;
                }
 
                if ($id == "feedBrowser") {
 
-                       print "<div id=\"infoBoxTitle\">".__('Feed Browser')."</div>";
+                       print "<title>".__('Feed Browser')."</title>";
                        
-                       print "<div class=\"infoBoxContents\">";
+                       print "<content><![CDATA[";
 
                        $browser_search = db_escape_string($_REQUEST["search"]);
                        
 
                        $owner_uid = $_SESSION["uid"];
 
-/*                     print   __('Select:')." 
-                               <a href=\"javascript:selectPrefRows('fbrowse', true)\">".__('All')."</a>,
-                                       <a href=\"javascript:selectPrefRows('fbrowse', false)\">".__('None')."</a>"; */
-
                        print "<ul class='browseFeedList' id='browseFeedList'>";
                        print_feed_browser($link, $search, 25);
                        print "</ul>";
                                <button style='display : none' id='feed_archive_remove' onclick=\"feedArchiveRemove()\">".__('Remove')."</button>
                                <button onclick=\"closeInfoBox()\" >".__('Cancel')."</button></div>";
 
-                       print "</div>";
-                       return;
+                       print "]]></content>";
+                       //return;
                }
 
                if ($id == "search") {
 
-                       print "<div id=\"infoBoxTitle\">".__('Search')."</div>";
-                       print "<div class=\"infoBoxContents\">";
+                       print "<title>".__('Search')."</title>";
+                       print "<content><![CDATA[";
 
                        print "<form id='search_form'  onsubmit='return false'>";
 
                        #$active_feed_id = db_escape_string($_REQUEST["param"]);
 
-                       $params = split(":", db_escape_string($_REQUEST["param"]));
+                       $params = explode(":", db_escape_string($_REQUEST["param"]), 2);
 
                        $active_feed_id = sprintf("%d", $params[0]);
-                       $is_cat = $params[1] == "true";
+                       $is_cat = (bool) $params[1];
 
                        print "<div class=\"dlgSec\">".__('Look for')."</div>";
 
                        print "<div class=\"dlgSecCont\">";
 
-                       print "<input onkeypress=\"return filterCR(event, search)\"
-                               name=\"query\" size=\"20\" type=\"search\"      value=''>";
+                       if (!SPHINX_ENABLE) {
 
-                       print " " . __('match on')." ";
+                               print "<input onkeypress=\"return filterCR(event, search)\"
+                                       name=\"query\" size=\"20\" type=\"search\"      value=''>";
 
-                       $search_fields = array(
-                               "title" => __("Title"),
-                               "content" => __("Content"),
-                               "both" => __("Title or content"));
+                               print " " . __('match on')." ";
 
-                       print_select_hash("match_on", 3, $search_fields); 
+                               $search_fields = array(
+                                       "title" => __("Title"),
+                                               "content" => __("Content"),
+                                       "both" => __("Title or content"));
+       
+                               print_select_hash("match_on", 3, $search_fields); 
+                       } else {
+                               print "<input onkeypress=\"return filterCR(event, search)\"
+                                       name=\"query\" size=\"50\" type=\"search\"      value=''>";
+                       }
 
 
                        print "<br/>".__('Limit search to:')." ";
                        <button onclick=\"javascript:closeInfoBox(true)\">".__('Cancel')."</button>
                        </div>";
 
-                       print "</div>";
+                       print "]]></content>";
 
-                       return;
+                       //return;
 
                }
 
 
                        $active_feed_id = db_escape_string($_REQUEST["param"]);
 
-                       print "<div id=\"infoBoxTitle\">".__('Create Filter')."</div>";
-                       print "<div class=\"infoBoxContents\">";
+                       print "<title>".__('Create Filter')."</title>";
+                       print "<content><![CDATA[";
 
                        print "<form id=\"filter_add_form\" onsubmit='return false'>";
 
                                 name=\"reg_exp\" size=\"30\" value=\"$reg_exp\">";
 
                        print "<span id=\"filter_dlg_date_chk_box\" style=\"display : none\">";
-                       print "&nbsp;<input class=\"button\"
-                               type=\"submit\" onclick=\"return filterDlgCheckDate()\" 
-                               value=\"".__('Check it')."\">";
+                       print "&nbsp;<button onclick=\"return filterDlgCheckDate()\">".
+                               __('Check it')."</button>";
                        print "</span>";
 
                        print "<br/> " . __("on field") . " ";
                        print "<button onclick=\"return closeInfoBox()\">".__('Cancel').
                                "</button>";
 
-                       print "</div>";
+                       print "]]></content>";
 
 //                     print "</td></tr></table>"; 
 
-                       return;
+                       //return;
                }
 
                if ($id == "feedUpdateErrors") {
 
-                       print "<div id=\"infoBoxTitle\">".__('Update Errors')."</div>";
-                       print "<div class=\"infoBoxContents\">";
+                       print "<title>".__('Update Errors')."</title>";
+                       print "<content><![CDATA[";
 
                        print __("These feeds have not been updated because of errors:");
 
                        print "<button onclick=\"return closeInfoBox()\">".
                                __('Close this window')."</button>";
 
-                       print "</div>";
+                       print "]]></content>";
 
-                       return;
+                       //return;
                }
 
                if ($id == "editArticleTags") {
 
-                       print "<div id=\"infoBoxTitle\">".__('Edit Tags')."</div>";
-                       print "<div class=\"infoBoxContents\">";
+                       print "<title>".__('Edit Tags')."</title>";
+                       print "<content><![CDATA[";
 
                        print "<form id=\"tag_edit_form\" onsubmit='return false'>";
 
                        print "<button onclick=\"return editTagsSave()\">".__('Save')."</button> ";
                        print "<button onclick=\"return closeInfoBox()\">".__('Cancel')."</button>";
 
-                       print "</div>";
+                       print "]]></content>";
 
-                       return;
+                       //return;
                }
 
                if ($id == "printTagCloud") {
-                       print "<div id=\"infoBoxTitle\">".__('Tag Cloud')."</div>";
-                       print "<div class=\"infoBoxContents\">";
+                       print "<title>".__('Tag Cloud')."</title>";
+                       print "<content><![CDATA[";
 
                        print __("Showing most popular tags ")." (<a 
                        href='javascript:toggleTags(true)'>".__('more tags')."</a>):<br/>"; 
                                __('Close this window')."</button>";
                        print "</div>";
 
-                       print "</div>";
+                       print "]]></content>";
 
-                       return;
+                       //return;
                }
 
-/*             if ($id == "offlineDownload") {
-                       print "<div id=\"infoBoxTitle\">".__('Download articles')."</div>";
-                       print "<div class=\"infoBoxContents\">";
+               if ($id == "emailArticle") {
 
-                       print "<form name='download_ops_form' id='download_ops_form'>";
+                       print "<title>".__('Forward article by email')."</title>";
+                       print "<content><![CDATA[";
 
-                       print "<div class=\"dlgSec\">".__("Download")."</div>";
+                       print "<form id=\"article_email_form\" onsubmit='return false'>";
 
-                       print "<div class=\"dlgSecCont\">";
+                       $secretkey = sha1(uniqid(rand(), true));
 
-                       $amount = array(
-                               50  => 50,
-                               100 => 100,
-                               250 => 250,
-                               500 => 500);
+                       $_SESSION['email_secretkey'] = $secretkey;
 
-                       print_select_hash("amount", 50, $amount);
+                       print "<input type=\"hidden\" name=\"secretkey\" value=\"$secretkey\">";
+                       print "<input type=\"hidden\" name=\"op\" value=\"rpc\">";
+                       print "<input type=\"hidden\" name=\"subop\" value=\"sendEmail\">"; 
 
-                       print " " . __("latest articles for offline reading.");
+                       $result = db_query($link, "SELECT email, full_name FROM ttrss_users WHERE
+                               id = " . $_SESSION["uid"]);
 
-                       print "<br/>";
+                       $user_email = htmlspecialchars(db_fetch_result($result, 0, "email"));
+                       $user_name = htmlspecialchars(db_fetch_result($result, 0, "full_name"));
 
-                       print "<input checked='yes' type='checkbox' name='unread_only' id='unread_only'>";
-                       print "<label for='unread_only'>".__('Only include unread articles')."</label>";
+                       if (!$user_name) $user_name = $_SESSION['name'];
 
-                       print "</div>";
+                       $_SESSION['email_replyto'] = $user_email;
+                       $_SESSION['email_fromname'] = $user_name;
+
+                       require_once "lib/MiniTemplator.class.php";
+
+                       $tpl = new MiniTemplator;
+                       $tpl_t = new MiniTemplator;
+
+                       $tpl->readTemplateFromFile("templates/email_article_template.txt");
+
+                       $tpl->setVariable('USER_NAME', $_SESSION["name"]);
+                       $tpl->setVariable('USER_EMAIL', $user_email);
+                       $tpl->setVariable('TTRSS_HOST', $_SERVER["HTTP_HOST"]);
+
+//                     $tpl->addBlock('header');
+
+                       $result = db_query($link, "SELECT link, content, title
+                               FROM ttrss_user_entries, ttrss_entries WHERE id = ref_id AND
+                               id IN ($param) AND owner_uid = " . $_SESSION["uid"]);
+
+                       if (db_num_rows($result) > 1) {
+                               $subject = __("[Forwarded]") . " " . __("Multiple articles");
+                       }
+
+                       while ($line = db_fetch_assoc($result)) {
+
+                               if (!$subject)
+                                       $subject = __("[Forwarded]") . " " . htmlspecialchars($line["title"]);
+
+                               $tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"]));
+                               $tpl->setVariable('ARTICLE_URL', strip_tags($line["link"]));
+
+                               $tpl->addBlock('article');
+                       }
+
+                       $tpl->addBlock('email');
+
+                       $content = "";
+                       $tpl->generateOutputToString($content);
+
+                       print "<table width='100%'><tr><td>";
+
+                       print __('From:');
+
+                       print "</td><td>";
+
+                       print "<input size=\"40\" disabled
+                                       onkeypress=\"return filterCR(event, false)\"
+                                       value=\"$user_name <$user_email>\">";
+
+                       print "</td></tr><tr><td>";
+
+                       print __('To:');
+
+                       print "</td><td>";
+
+                       print "<input size=\"40\"
+                                       onkeypress=\"return filterCR(event, false)\"
+                                       name=\"destination\" id=\"destination\">";
+
+                       print "<div class=\"autocomplete\" id=\"destination_choices\" 
+                                       style=\"display:none\"></div>"; 
+
+                       print "</td></tr><tr><td>";
+
+                       print __('Subject:');
+
+                       print "</td><td>";
+
+                       print "<input size=\"60\" class=\"iedit\"
+                                       onkeypress=\"return filterCR(event, false)\"
+                                       name=\"subject\" value=\"$subject\" id=\"subject\">";
+
+                       print "</td></tr></table>";
+
+                       print "<textarea rows='10' class='iedit' style='font-size : small'
+                               name='content'>$content</textarea>";
 
                        print "</form>";
 
-                       print "<div class=\"dlgButtons\">
-                               <input class=\"button\"
-                                       type=\"submit\" onclick=\"return initiate_offline_download(0, this)\" value=\"".__('Download')."\">
-                               <input class=\"button\"
-                                       type=\"submit\" onclick=\"return closeInfoBox()\" 
-                                       value=\"".__('Cancel')."\"></div>";
+                       print "<div class='dlgButtons'>";
 
-                       print "</div>";
+                       print "<button onclick=\"return emailArticleDo()\">".__('Send e-mail')."</button> ";
+                       print "<button onclick=\"return closeInfoBox()\">".__('Cancel')."</button>";
+
+                       print "]]></content>";
 
-                       return;
-               } */
+                       //return;
+               }
 
+               if ($id == "generatedFeed") {
 
-               print "<div id='infoBoxTitle'>Internal Error</div>
-                       <div id='infoBoxContents'>
-                       <p>Unknown dialog <b>$id</b></p>
-                       </div></div>";
+                       print "<title>".__('View as RSS')."</title>";
+                       print "<content><![CDATA[";
        
+                       $params = explode(":", $param, 3);
+                       $feed_id = db_escape_string($params[0]);
+                       $is_cat = (bool) $params[1];
+
+                       $key = get_feed_access_key($link, $feed_id, $is_cat);
+
+                       $url_path = htmlspecialchars($params[2]) . "&key=" . $key;
+
+                       print __("You can view this feed as RSS using the following URL:");
+
+                       print "<div class=\"tagCloudContainer\">";
+                       print "<a id='gen_feed_url' href='$url_path' target='_blank'>$url_path</a>";
+                       print "</div>";
+
+                       print "<div align='center'>";
+
+                       print "<button onclick=\"return genUrlChangeKey('$feed_id', '$is_cat')\">".
+                               __('Generate new URL')."</button> ";
+
+                       print "<button onclick=\"return closeInfoBox()\">".
+                               __('Close this window')."</button>";
+
+                       print "</div>";
+                       print "]]></content>";
+
+                       //return;
+               }
+
+               print "</dlg>"; 
        }
 ?>