Commit 68f29f41 authored by Clare Lenihan's avatar Clare Lenihan Committed by Clare Lenihan
Browse files

changing format_text so it preserves <p>s and <br>s

parent 57b33b31
......@@ -15,7 +15,7 @@
{/if}
<td>
<a href="{$WWWROOT}interaction/forum/topic.php?id={$topic->id|escape}">{$topic->subject|escape}</a>
<div>{$topic->body|escape}</div>
<div>{$topic->body}</div>
</td>
<td>
<a href="{$WWWROOT}user/view.php?id={$topic->poster}"
......
......@@ -345,6 +345,7 @@ function setup_groups($groups, $returnto='mygroups') {
}
$i = 0;
foreach ($groups as $group) {
$group->description = format_text($group->description);
if ($group->type == 'member') {
$group->canleave = group_user_can_leave($group->id);
}
......
......@@ -1768,6 +1768,10 @@ function format_text($string, $length=100, $extra=10, $newlines=true) {
$more = true;
}
}
// so newlines don't disappear.
$string = str_replace('<p', "%p<p", $string);
$string = str_replace('<br', "%br<br", $string);
$string = strip_tags($string);
$string = html_entity_decode($string); // no things like &nbsp; only take up one character
// take the first $length chars, then up to the first space (max length $length + $extra chars)
......@@ -1782,7 +1786,9 @@ function format_text($string, $length=100, $extra=10, $newlines=true) {
if ($more) {
$string .= '...';
}
return hsc($string);
$string = hsc($string);
$string = str_replace('%p', '<p>', $string);
return str_replace('%br', '<br>', $string);
}
?>
......@@ -20,7 +20,7 @@
<tr>
<td id="friendinfo_{$user->id}">
{if $user->introduction}
{$user->introduction|escape}
{$user->introduction}
{/if}
<div class="pending">
<strong>
......@@ -93,7 +93,7 @@
<td id="friendinfo_{$user->id}">
{if $user->introduction}
<p>
{$user->introduction|escape}
{$user->introduction}
</p>
{/if}
<ul>
......@@ -135,7 +135,7 @@
<tr>
<td id="friendinfo_{$user->id}">
{if $user->introduction}
{$user->introduction|escape}
{$user->introduction}
{/if}
<div>
<ul>
......@@ -181,7 +181,7 @@
<tr>
<td id="friendinfo_{$user->id}">
{if $user->introduction}
{$user->introduction|escape}
{$user->introduction}
{/if}
<div>
<ul>
......
......@@ -108,7 +108,7 @@ if ($allviews = get_records_array('view', 'owner', $userid)) {
if (can_view_view($view->id)) {
$views[$view->id] = $view;
$view->artefacts = array();
$view->description = format_description($view->description);
$view->description = format_text($view->description);
}
}
}
......@@ -148,7 +148,7 @@ if (!$userassocgroups = get_associated_groups($userid, false)) {
}
foreach ($userassocgroups as $group) {
$group->description = format_description($group->description);
$group->description = format_text($group->description);
}
if (is_postgres()) {
......@@ -326,15 +326,6 @@ $smarty->assign('friends', $friends);
$smarty->assign('friendsmessage', $friendsmessage);
$smarty->display('user/view.tpl');
function format_description($description) {
$description = strip_tags($description);
// Note: the lengths are different to prevent chopping off just one or two characters in order to add an ellipsis
if (strlen($description) < 110) {
return $description;
}
return substr($description, 0, 100) . '...';
}
// Send an invitation to the user to join a group
function invite_submit(Pieform $form, $values) {
global $userid;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment