summaryrefslogtreecommitdiff
path: root/classes/pref/labels.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2021-02-13 13:17:34 +0300
committerAndrew Dolgov <[email protected]>2021-02-13 13:17:34 +0300
commite7924c6dacef405a6e20b41d078f4a90a210cb51 (patch)
tree59d6036fc12a16bc463db7463956fce9ecd0bd9c /classes/pref/labels.php
parent0b71729bd3eea52e92019349d2057f47e291bb31 (diff)
label editor: use client dialog
Diffstat (limited to 'classes/pref/labels.php')
-rw-r--r--classes/pref/labels.php68
1 files changed, 5 insertions, 63 deletions
diff --git a/classes/pref/labels.php b/classes/pref/labels.php
index a787ce388..6102ab8dd 100644
--- a/classes/pref/labels.php
+++ b/classes/pref/labels.php
@@ -10,72 +10,14 @@ class Pref_Labels extends Handler_Protected {
function edit() {
$label_id = clean($_REQUEST['id']);
- $sth = $this->pdo->prepare("SELECT * FROM ttrss_labels2 WHERE
+ $sth = $this->pdo->prepare("SELECT id, caption, fg_color, bg_color FROM ttrss_labels2 WHERE
id = ? AND owner_uid = ?");
$sth->execute([$label_id, $_SESSION['uid']]);
- if ($line = $sth->fetch()) {
-
- print_hidden("id", "$label_id");
- print_hidden("op", "pref-labels");
- print_hidden("method", "save");
-
- print "<form onsubmit='return false;'>";
-
- print "<header>".__("Caption")."</header>";
-
- print "<section>";
-
- $fg_color = $line['fg_color'];
- $bg_color = $line['bg_color'] ? $line['bg_color'] : '#fff7d5';
-
- print "<input style='font-size : 16px; color : $fg_color; background : $bg_color; transition : background 0.1s linear'
- id='labelEdit_caption' name='caption' dojoType='dijit.form.ValidationTextBox'
- required='true' value=\"".htmlspecialchars($line['caption'])."\">";
-
- print "</section>";
-
- print "<header>" . __("Colors") . "</header>";
- print "<section>";
-
- print "<table>";
- print "<tr><th style='text-align : left'>".__("Foreground:")."</th><th style='text-align : left'>".__("Background:")."</th></tr>";
- print "<tr><td style='padding-right : 10px'>";
-
- print "<input dojoType='dijit.form.TextBox'
- style='display : none' id='labelEdit_fgColor'
- name='fg_color' value='$fg_color'>";
- print "<input dojoType='dijit.form.TextBox'
- style='display : none' id='labelEdit_bgColor'
- name='bg_color' value='$bg_color'>";
-
- print "<div dojoType='dijit.ColorPalette'>
- <script type='dojo/method' event='onChange' args='fg_color'>
- dijit.byId('labelEdit_fgColor').attr('value', fg_color);
- dijit.byId('labelEdit_caption').domNode.setStyle({color: fg_color});
- </script>
- </div>";
-
- print "</td><td>";
-
- print "<div dojoType='dijit.ColorPalette'>
- <script type='dojo/method' event='onChange' args='bg_color'>
- dijit.byId('labelEdit_bgColor').attr('value', bg_color);
- dijit.byId('labelEdit_caption').domNode.setStyle({backgroundColor: bg_color});
- </script>
- </div>";
-
- print "</td></tr></table>";
- print "</section>";
-
- print "<footer>";
- print "<button dojoType='dijit.form.Button' type='submit' class='alt-primary' onclick='App.dialogOf(this).execute()'>".
- __('Save')."</button>";
- print "<button dojoType='dijit.form.Button' onclick='App.dialogOf(this).hide()'>".
- __('Cancel')."</button>";
- print "</footer>";
-
- print "</form>";
+ if ($line = $sth->fetch(PDO::FETCH_ASSOC)) {
+ print json_encode($line);
+ } else {
+ print json_encode(["error" => "LABEL_NOT_FOUND"]);
}
}