API: beautify the output of repeated items

Vier: Birthday reminder looks better
This commit is contained in:
Michael Vogel 2013-02-15 20:14:45 +01:00
parent 5e077e541a
commit 3e58060b30
3 changed files with 55 additions and 21 deletions

View file

@ -639,7 +639,7 @@
$in_reply_to_screen_name = $lastwall['reply_author'];
}
$status_info = array(
'text' => html2plain(bbcode($lastwall['body']), 0),
'text' => html2plain(bbcode($lastwall['body'], false, false, true), 0),
'truncated' => false,
'created_at' => api_date($lastwall['created']),
'in_reply_to_status_id' => $in_reply_to_status_id,
@ -698,7 +698,7 @@
$user_info['status'] = array(
'created_at' => api_date($lastwall['created']),
'id' => $lastwall['contact-id'],
'text' => html2plain(bbcode($lastwall['body']), 0),
'text' => html2plain(bbcode($lastwall['body'], false, false, true), 0),
'source' => (($lastwall['app']) ? $lastwall['app'] : 'web'),
'truncated' => false,
'in_reply_to_status_id' => $in_reply_to_status_id,
@ -1300,11 +1300,11 @@
$ret['text'] = bbcode($item['body']);
}
elseif ($_GET["getText"] == "plain") {
$ret['text'] = html2plain(bbcode($item['body']), 0);
$ret['text'] = html2plain(bbcode($item['body'], false, false, true), 0);
}
}
else {
$ret['text'] = $item['title']."\n".html2plain(bbcode($item['body']), 0);
$ret['text'] = $item['title']."\n".html2plain(bbcode($item['body'], false, false, true), 0);
}
if (isset($_GET["getUserObjects"]) && $_GET["getUserObjects"] == "false") {
unset($ret['sender']);
@ -1348,7 +1348,7 @@
}
// Workaround for ostatus messages where the title is identically to the body
$statusbody = trim(html2plain(bbcode($item['body']), 0));
$statusbody = trim(html2plain(bbcode($item['body'], false, false, true), 0));
$statustitle = trim($item['title']);
if (($statustitle != '') and (strpos($statusbody, $statustitle) !== false))

View file

@ -278,10 +278,37 @@ function bb_ShareAttributes($match) {
return($text);
}
function bb_ShareAttributesSimple($match) {
$attributes = $match[1];
$author = "";
preg_match("/author='(.*?)'/ism", $attributes, $matches);
if ($matches[1] != "")
$author = html_entity_decode($matches[1],ENT_QUOTES,'UTF-8');
preg_match('/author="(.*?)"/ism', $attributes, $matches);
if ($matches[1] != "")
$author = $matches[1];
$profile = "";
preg_match("/profile='(.*?)'/ism", $attributes, $matches);
if ($matches[1] != "")
$profile = $matches[1];
preg_match('/profile="(.*?)"/ism', $attributes, $matches);
if ($matches[1] != "")
$profile = $matches[1];
$text = "<br />".html_entity_decode("&#x2672; ", ENT_QUOTES, 'UTF-8').' <a href="'.$profile.'">'.$author."</a>: <br />»".$match[2]."«";
return($text);
}
// BBcode 2 HTML was written by WAY2WEB.net
// extended to work with Mistpark/Friendica - Mike Macgirvin
function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = false) {
$stamp1 = microtime(true);
@ -342,13 +369,14 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
$Text = str_replace("\r\n","\n", $Text);
// removing multiplicated newlines
// $search = array("\n\n\n", "\n ", " \n", "[/quote]\n\n", "\n[/quote]");
// $replace = array("\n\n", "\n", "\n", "[/quote]\n", "[/quote]");
// do {
// $oldtext = $Text;
// $Text = str_replace($search, $replace, $Text);
// } while ($oldtext != $Text);
if (get_config("system", "remove_multiplicated_lines")) {
$search = array("\n\n\n", "\n ", " \n", "[/quote]\n\n", "\n[/quote]");
$replace = array("\n\n", "\n", "\n", "[/quote]\n", "[/quote]");
do {
$oldtext = $Text;
$Text = str_replace($search, $replace, $Text);
} while ($oldtext != $Text);
}
$Text = str_replace(array("\r","\n"), array('<br />','<br />'), $Text);
@ -517,7 +545,10 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
$Text = preg_replace("/\[img\](.*?)\[\/img\]/ism", '<img src="$1" alt="' . t('Image/photo') . '" />', $Text);
// Shared content
if (!$simplehtml)
$Text = preg_replace_callback("/\[share(.*?)\](.*?)\[\/share\]/ism","bb_ShareAttributes",$Text);
else
$Text = preg_replace_callback("/\[share(.*?)\](.*?)\[\/share\]/ism","bb_ShareAttributesSimple",$Text);
$Text = preg_replace("/\[crypt\](.*?)\[\/crypt\]/ism",'<br/><img src="' .$a->get_baseurl() . '/images/lock_icon.gif" alt="' . t('Encrypted content') . '" title="' . t('Encrypted content') . '" /><br />', $Text);
$Text = preg_replace("/\[crypt=(.*?)\](.*?)\[\/crypt\]/ism",'<br/><img src="' .$a->get_baseurl() . '/images/lock_icon.gif" alt="' . t('Encrypted content') . '" title="' . '$1' . ' ' . t('Encrypted content') . '" /><br />', $Text);

View file

@ -1020,6 +1020,9 @@ section {
max-width: 766px;
padding: 10px 10px 10px 10px;
background-color: white;
border-bottom: 1px solid lightgray;
border-right: 1px solid lightgray;
border-left: 1px solid lightgray;
}
/* wall item */
.tread-wrapper {
@ -1727,7 +1730,7 @@ div.pager, .birthday-notice, ul.tabs a, #jot-preview-link, .comment-edit-submit-
background: linear-gradient(top, #ffffff 0%,#ececf2 100%);*/
}
#event-notice:hover, ul.tabs li .active, ul.tabs a:hover, #jot-preview-link:hover, .comment-edit-submit-wrapper .fakelink:hover {
#event-notice:hover, #birthday-notice:hover, ul.tabs li .active, ul.tabs a:hover, #jot-preview-link:hover, .comment-edit-submit-wrapper .fakelink:hover {
color: black;
background-color: #e5e5e5;
text-decoration: none;