mirror of
https://github.com/friendica/friendica
synced 2024-11-09 23:02:54 +00:00
Merge pull request #14406 from friendica/issue-14294
Issue 14294: Fix event parsing
This commit is contained in:
commit
ee24685cd7
4 changed files with 3301 additions and 3302 deletions
|
@ -1306,8 +1306,10 @@ class BBCode
|
|||
|
||||
Hook::callAll('bbcode', $text);
|
||||
|
||||
$text = self::performWithEscapedTags($text, ['code'], function ($text) use ($try_oembed, $simple_html, $for_plaintext, $uriid) {
|
||||
$text = self::performWithEscapedTags($text, ['noparse', 'nobb', 'pre'], function ($text) use ($try_oembed, $simple_html, $for_plaintext, $uriid) {
|
||||
$ev = Event::fromBBCode($text);
|
||||
|
||||
$text = self::performWithEscapedTags($text, ['code'], function ($text) use ($try_oembed, $simple_html, $for_plaintext, $uriid, $ev) {
|
||||
$text = self::performWithEscapedTags($text, ['noparse', 'nobb', 'pre'], function ($text) use ($try_oembed, $simple_html, $for_plaintext, $uriid, $ev) {
|
||||
/*
|
||||
* preg_match_callback function to replace potential Oembed tags with Oembed content
|
||||
*
|
||||
|
@ -1361,7 +1363,7 @@ class BBCode
|
|||
$text = self::convertQuotesToHtml($text);
|
||||
$text = self::convertVideoPlatformsToHtml($text, $try_oembed);
|
||||
$text = self::convertOEmbedToHtml($text, $uriid);
|
||||
$text = self::convertEventsToHtml($text, $simple_html, $uriid);
|
||||
$text = self::convertEventsToHtml($text, $simple_html, $uriid, $ev);
|
||||
|
||||
// Some simpler non standard elements
|
||||
$text = self::convertEmojisToHtml($text, $simple_html);
|
||||
|
@ -1510,14 +1512,12 @@ class BBCode
|
|||
return $text;
|
||||
}
|
||||
|
||||
private static function convertEventsToHtml(string $text, int $simple_html, int $uriid): string
|
||||
private static function convertEventsToHtml(string $text, int $simple_html, int $uriid, array $ev): string
|
||||
{
|
||||
// If we find any event code, turn it into an event.
|
||||
// After we're finished processing the bbcode we'll
|
||||
// replace all of the event code with a reformatted version.
|
||||
|
||||
$ev = Event::fromBBCode($text);
|
||||
|
||||
// If we found an event earlier, strip out all the event code and replace with a reformatted version.
|
||||
// Replace the event-start section with the entire formatted event. The other bbcode is stripped.
|
||||
// Summary (e.g. title) is required, earlier revisions only required description (in addition to
|
||||
|
|
|
@ -51,11 +51,11 @@ class Event
|
|||
$o = '';
|
||||
|
||||
if (!empty($event['summary'])) {
|
||||
$o .= "<h3>" . BBCode::convertForUriId($uriid, Strings::escapeHtml($event['summary']), $simple) . "</h3>";
|
||||
$o .= "<h3>" . strip_tags(BBCode::convertForUriId($uriid, $event['summary'], $simple)) . "</h3>";
|
||||
}
|
||||
|
||||
if (!empty($event['desc'])) {
|
||||
$o .= "<div>" . BBCode::convertForUriId($uriid, Strings::escapeHtml($event['desc']), $simple) . "</div>";
|
||||
$o .= "<div>" . BBCode::convertForUriId($uriid, $event['desc'], $simple) . "</div>";
|
||||
}
|
||||
|
||||
$o .= "<h4>" . DI::l10n()->t('Starts:') . "</h4><p>" . $event_start . "</p>";
|
||||
|
@ -65,7 +65,7 @@ class Event
|
|||
}
|
||||
|
||||
if (!empty($event['location'])) {
|
||||
$o .= "<h4>" . DI::l10n()->t('Location:') . "</h4><p>" . BBCode::convertForUriId($uriid, Strings::escapeHtml($event['location']), $simple) . "</p>";
|
||||
$o .= "<h4>" . DI::l10n()->t('Location:') . "</h4><p>" . strip_tags(BBCode::convertForUriId($uriid, $event['location'], $simple)) . "</p>";
|
||||
}
|
||||
|
||||
return $o;
|
||||
|
@ -73,7 +73,7 @@ class Event
|
|||
|
||||
$o = '<div class="vevent">' . "\r\n";
|
||||
|
||||
$o .= '<div class="summary event-summary">' . BBCode::convertForUriId($uriid, Strings::escapeHtml($event['summary']), $simple) . '</div>' . "\r\n";
|
||||
$o .= '<div class="summary event-summary">' . BBCode::convertForUriId($uriid, $event['summary'], $simple) . '</div>' . "\r\n";
|
||||
|
||||
$o .= '<div class="event-start"><span class="event-label">' . DI::l10n()->t('Starts:') . '</span> <span class="dtstart" title="'
|
||||
. DateTimeFormat::local($event['start'], DateTimeFormat::ATOM)
|
||||
|
@ -88,12 +88,12 @@ class Event
|
|||
}
|
||||
|
||||
if (!empty($event['desc'])) {
|
||||
$o .= '<div class="description event-description">' . BBCode::convertForUriId($uriid, Strings::escapeHtml($event['desc']), $simple) . '</div>' . "\r\n";
|
||||
$o .= '<div class="description event-description">' . BBCode::convertForUriId($uriid, $event['desc'], $simple) . '</div>' . "\r\n";
|
||||
}
|
||||
|
||||
if (!empty($event['location'])) {
|
||||
$o .= '<div class="event-location"><span class="event-label">' . DI::l10n()->t('Location:') . '</span> <span class="location">'
|
||||
. BBCode::convertForUriId($uriid, Strings::escapeHtml($event['location']), $simple)
|
||||
. strip_tags(BBCode::convertForUriId($uriid, $event['location'], $simple))
|
||||
. '</span></div>' . "\r\n";
|
||||
|
||||
// Include a map of the location if the [map] BBCode is used.
|
||||
|
@ -652,7 +652,7 @@ class Event
|
|||
$drop = ['calendar/api/delete/' . $event['id'], DI::l10n()->t('Delete event'), '', ''];
|
||||
}
|
||||
|
||||
$title = BBCode::convertForUriId($event['uri-id'], Strings::escapeHtml($event['summary']));
|
||||
$title = strip_tags(BBCode::convertForUriId($event['uri-id'], $event['summary']));
|
||||
if (!$title) {
|
||||
[$title, $_trash] = explode("<br", BBCode::convertForUriId($event['uri-id'], Strings::escapeHtml($event['desc'])), BBCode::TWITTER_API);
|
||||
}
|
||||
|
|
|
@ -3349,22 +3349,22 @@ class Diaspora
|
|||
}
|
||||
}
|
||||
|
||||
// convert to markdown
|
||||
$body = html_entity_decode(BBCode::toMarkdown($body));
|
||||
|
||||
// Adding the title
|
||||
if (strlen($title)) {
|
||||
$body = '### ' . html_entity_decode($title) . "\n\n" . $body;
|
||||
}
|
||||
|
||||
$attachments = Post\Media::getByURIId($item['uri-id'], [Post\Media::DOCUMENT, Post\Media::TORRENT]);
|
||||
if (!empty($attachments)) {
|
||||
$body .= "\n[hr]\n";
|
||||
foreach ($attachments as $attachment) {
|
||||
$body .= "[" . $attachment['description'] . "](" . $attachment['url'] . ")\n";
|
||||
$body .= "[url=" . $attachment['url'] . "]" . $attachment['description'] . "[/url]\n";
|
||||
}
|
||||
}
|
||||
|
||||
// convert to markdown
|
||||
$body = BBCode::toMarkdown($body);
|
||||
|
||||
// Adding the title
|
||||
if (strlen($title)) {
|
||||
$body = '### ' . html_entity_decode($title) . "\n\n" . $body;
|
||||
}
|
||||
|
||||
$location = [];
|
||||
|
||||
if ($item['location'] != '')
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue