]> git.wh0rd.org Git - tt-rss.git/commitdiff
test button for label editor
authorAndrew Dolgov <fox@madoka.spb.ru>
Thu, 24 Nov 2005 07:05:20 +0000 (08:05 +0100)
committerAndrew Dolgov <fox@madoka.spb.ru>
Thu, 24 Nov 2005 07:05:20 +0000 (08:05 +0100)
backend.php
prefs.js
tt-rss.css

index 327030e32da4e208062960d7f73c0b914784fff0..0ee60a3f8a9721d307bf18ebcc9c462df4cff898 100644 (file)
 
                $subop = $_GET["subop"];
 
+               if ($subop == "test") {
+
+                       $expr = $_GET["expr"];
+                       $descr = $_GET["descr"];
+
+                       print "<div class='infoBoxContents'>";
+               
+                       print "<h1>Label &laquo;$descr&raquo;</h1>";
+
+//                     print "<p><b>Expression</b>: $expr</p>";
+
+                       $result = db_query($link, 
+                               "SELECT count(id) AS num_matches
+                                       FROM ttrss_entries,ttrss_user_entries
+                                       WHERE ($expr) AND 
+                                               ttrss_user_entries.ref_id = ttrss_entries.id AND
+                                               owner_uid = " . $_SESSION["uid"]);
+
+                       $num_matches = db_fetch_result($result, 0, "num_matches");;
+                       
+                       if ($num_matches > 0) { 
+
+                               print "<p>Query returned <b>$num_matches</b> matches, first 5:</p>";
+
+                               $result = db_query($link, 
+                                       "SELECT title, 
+                                               (SELECT title FROM ttrss_feeds WHERE id = feed_id) AS feed_title
+                                       FROM ttrss_entries,ttrss_user_entries
+                                                       WHERE ($expr) AND 
+                                                       ttrss_user_entries.ref_id = ttrss_entries.id
+                                                       AND owner_uid = " . $_SESSION["uid"] . " 
+                                                       ORDER BY date_entered DESC LIMIT 5");
+
+                               print "<ul class=\"nomarks\">";
+                               while ($line = db_fetch_assoc($result)) {
+                                       print "<li>".$line["title"].
+                                               " <span class=\"insensitive\">(".$line["feed_title"].")</span></li>";
+                               }
+                               print "</ul>";
+
+                       } else {
+                               print "<p>Query didn't return any matches.</p>";
+                       }
+
+                       print "</div>";
+
+                       print "<div align='center'>
+                               <input type='submit' class='button'                     
+                               onclick=\"closeInfoBox()\" value=\"Close this window\"></div>";
+                       return;
+               }
+
                if ($subop == "editSave") {
 
                        $sql_exp = $_GET["s"];
                                owner_uid = ".$_SESSION["uid"]."
                        ORDER by description");
 
+               print "<div id=\"infoBoxShadow\"><div id=\"infoBox\">PLACEHOLDER</div></div>";
+
                if (db_num_rows($result) != 0) {
 
                        print "<p><table width=\"100%\" class=\"prefLabelList\" id=\"prefLabelList\">";
        
                        if ($subop == "edit") {
                                print "Edit label:
+                                       <input type=\"submit\" class=\"button\" 
+                                               onclick=\"javascript:labelTest()\" value=\"Test\">
                                        <input type=\"submit\" class=\"button\" 
                                                onclick=\"javascript:labelEditCancel()\" value=\"Cancel\">
                                        <input type=\"submit\" class=\"button\" 
index 04b3138367697969974506028717bb7a1e10a728..c000ca19b14932500ff101b394ca363936bd7071 100644 (file)
--- a/prefs.js
+++ b/prefs.js
@@ -706,6 +706,19 @@ function feedEditSave() {
 
 }
 
+function labelTest() {
+
+       var sqlexp = document.getElementById("iedit_expr").value;
+       var descr = document.getElementById("iedit_descr").value;
+
+       xmlhttp.open("GET", "backend.php?op=pref-labels&subop=test&expr=" +
+               param_escape(sqlexp) + "&descr=" + param_escape(descr), true);
+
+       xmlhttp.onreadystatechange=infobox_callback;
+       xmlhttp.send(null);
+
+}
+
 function labelEditCancel() {
 
        if (!xmlhttp_ready(xmlhttp)) {
index 5e598f714941341ec6b1cc8d9065024d6b45d97e..6d682a1b35ed44427837266b075b0c8737168ac5 100644 (file)
@@ -657,3 +657,7 @@ div.logoutContent {
        margin-top : 20px;
        padding : 10px;
 }
+
+.small {
+       font-size : small;
+}