diff options
author | zotlabs <mike@macgirvin.com> | 2018-03-03 13:52:55 -0800 |
---|---|---|
committer | zotlabs <mike@macgirvin.com> | 2018-03-03 13:52:55 -0800 |
commit | c3920116f2fbf994f63b8bf9d190b16699cb93c0 (patch) | |
tree | be1e18f79be5c9f9c803ebe2da0c6913492c5e39 /include | |
parent | 26e0fd624ab282149ad8c4274f0e0ddd32b929d1 (diff) | |
download | volse-hubzilla-c3920116f2fbf994f63b8bf9d190b16699cb93c0.tar.gz volse-hubzilla-c3920116f2fbf994f63b8bf9d190b16699cb93c0.tar.bz2 volse-hubzilla-c3920116f2fbf994f63b8bf9d190b16699cb93c0.zip |
more work on federated polls
Diffstat (limited to 'include')
-rw-r--r-- | include/bbcode.php | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/include/bbcode.php b/include/bbcode.php index 03a46444b..b33766757 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -668,6 +668,31 @@ function bb_fixtable_lf($match) { } +function bbtopoll($s) { + + $pl = []; + + $match = ''; + if(! preg_match("/\[poll=(.*?)\](.*?)\[\/poll\]/ism",$s,$match)) { + return null; + } + $pl['poll_id'] = $match[1]; + $pl['poll_question'] = $match[2]; + + $match = ''; + if(preg_match_all("/\[poll\-answer=(.*?)\](.*?)\[\/poll\-answer\]/is",$s,$match,PREG_SET_ORDER)) { + $pl['answer'] = []; + foreach($match as $m) { + $ans = [ 'answer_id' => $m[1], 'answer_text' => $m[2] ]; + $pl['answer'][] = $ans; + } + } + + return $pl; + +} + + function parseIdentityAwareHTML($Text) { // Hide all [noparse] contained bbtags by spacefying them @@ -766,6 +791,11 @@ function bbcode($Text, $options = []) { $ev = bbtoevent($Text); + // and the same with polls + + $pl = bbtopoll($Text); + + // process [observer] tags before we do anything else because we might // be stripping away stuff that then doesn't need to be worked on anymore |