1
0
mirror of https://git.tt-rss.org/git/tt-rss.git synced 2025-12-13 01:46:00 +00:00

css: make plugin button container a flexbox

backend: pass plugin button generated code through domdocument to ensure
its correctness; set data-plugin-name attribute on children to make
them sortable via css
This commit is contained in:
Andrew Dolgov
2021-10-24 20:11:49 +03:00
parent 9f734c9050
commit 933913410c
9 changed files with 118 additions and 4 deletions

View File

@@ -230,17 +230,43 @@ class Feeds extends Handler_Protected {
$line["feed_title"] = $line["feed_title"] ?? "";
$button_doc = new DOMDocument();
$line["buttons_left"] = "";
PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_ARTICLE_LEFT_BUTTON,
function ($result) use (&$line) {
$line["buttons_left"] .= $result;
function ($result, $plugin) use (&$line, &$button_doc) {
if ($button_doc->loadXML($result)) {
/** @var DOMElement|null */
$child = $button_doc->firstChild;
if ($child) {
do {
$child->setAttribute('data-plugin-name', get_class($plugin));
} while ($child = $child->nextSibling);
$line["buttons_left"] .= $button_doc->saveXML($button_doc->firstChild);
}
}
},
$line);
$line["buttons"] = "";
PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_ARTICLE_BUTTON,
function ($result) use (&$line) {
$line["buttons"] .= $result;
function ($result, $plugin) use (&$line, &$button_doc) {
if ($button_doc->loadXML($result)) {
/** @var DOMElement|null */
$child = $button_doc->firstChild;
if ($child) {
do {
$child->setAttribute('data-plugin-name', get_class($plugin));
} while ($child = $child->nextSibling);
$line["buttons"] .= $button_doc->saveXML($button_doc->firstChild);
}
}
},
$line);