Closed taravasya closed 2 years ago
I think I I have one guess. With almost all the plugins that I have tried, when saving a message and check it in DB, saved with them text are not just framed in [LOGIN] hidden conten [/LOGIN]
tags, but they also add special xml markup. Like this:
<p><s>[LOGIN]</s>hidden content<e>[/LOGIN]</e></p>
When I tried to save messages with your plugin, I noticed that the text is stored in the database without the xml markup: <p>[LOGIN] hidden conten [/LOGIN]</p>
and decided that there is no need to add this markup when importing messages into the database...
However, now it turned out that this markup still needs to be added. When I corrected the message directly in the database by adding markup, all tag options began to work correctly. Without this markup, behavior becomes unpredictable. Tags are sometimes hidden and sometimes not
Thus, it turns out that I made a mistake, but this happened, because, apparently, you made a mistake at first))))
Ups... With
<p><s>[LOGIN]</s>hidden content<e>[/LOGIN]</e></p>
content stay visible for guests.... So... here may be need more attention...
I tried changing the regular expression in \vendor\datlechin\flarum-bbcode-hide-content\src\HideContentInPosts.php to something like this:
$contentHtml = preg_replace('/<s>\[LOGIN\](.*?)\[\/LOGIN\]<\/e>/s', $this->loginHtml(), $contentHtml);
and now everything work as expected.
But its just guess and I dont know if this right method? I am very poorly oriented in the flarum. Maybe it should be done differently...
I tried creating a new post using [LOGIN]content[/LOGIN]
, the content in the database is still [LOGIN]content[/LOGIN]
, I don't see any HTML markup added as you described like <s>
or <e>
both
That's the point. Now try to use as example:
[B] content [/B]
and look at this in db. It will look like this:
<p><s>[B]</s> content <e>[/B]</e></p>
It can be mistaken, but I think flarum use this <s></s><e></e>
tags, to escape bbcodes tags and hide them in frontend.
Ahh,
I see, so we need to add <s> <e>
tag into db or just use regular expression as you described?
I think both of them. One won't work without the other. After all, if you save text with these tags <s><e>
then the regular expression in your plugin stops render content porperly, because it looks for [LOGIN] text [/LOGIN]
, but not <s>[LOGIN]</s> text <e>[/LOGIN]</e>
.
However, I think it's worth checking my guesses with some other plugin that was created by a person who knows exactly how the most optimal parser / renderer should be made for Flarum.
I noticed that the last commit is missing from the composer repository (when updating the flarum plugin). I manually edited the code in accordance with this commit, and now when directly importing messages into the database, all tags work as expected and no additional tags <s><e>
are required.
So I think nothing else to do with this issue.
Ahhh... Sorry, but no..
For logged in user, still visible [LOGIN] [/LOGIN]
tags, then content was imported directly to DB
Does [LOGIN] [/LOGIN]
have <e><s>
in the database?
I manually edited the code in accordance with this commit, and now when directly importing messages into the database
I'm not ready to release a version for that commit yet
Does [LOGIN] [/LOGIN] have
<e><s>
in the database?
No. I was trying with them too, but it did`t help.
Here first link hidden with REPLY, second with LOGIN
Now I figured out exactly what is the reason for the remaining tags! )))
Let's imagine three users. user1 (logged in) user2 (logged in) user3 - guest (not logged in)
User1 posted a message.
For User1, the content remains visible, the tags are hidden. (everything is working properly) [ v ] For user2, the content remains visible, but the tags also remain visible (half correct). [ x ] For user3, both tags and content are hidden. (everything is working properly) [ v ]
It should be works now ^^, I'll release new version
Yes! I edit file with myself, and now its working! Thanks!
Hi! Its me again ))) Strange behavior. Then I import direct to DB, posts with wrapped [LOGIN][/LOGIN] tags content, I can see the tags themselves in posts. If I import posts with wrapped [REPLY][/REPLY] or [LIKE][/LIKE] tags, then all work as expected:
Logged in user and LOGIN tags:
Logged in user and REPLY / LIKE tags:
Guets and any of tags: