Commit 9c11b14d authored by Dries's avatar Dries
Browse files

- Bugfixes by Marco.

- Attempt to fix linebreak handling.
parent c7602236
......@@ -78,19 +78,19 @@ function node_teaser($body) {
}
if ($length = strpos($body, "<br />", $size)) {
return substr($body, 0, $length + 1);
return substr($body, 0, $length + 6);
}
if ($length = strpos($body, "<br>", $size)) {
return substr($body, 0, $length + 1);
return substr($body, 0, $length + 4);
}
if ($length = strpos($body, "</p>", $size)) {
return substr($body, 0, $length + 1);
return substr($body, 0, $length + 4);
}
/*
** When even the first paragraph is too long, try to
** When even the first paragraph is too long, try to
** split at the end of the next sentence.
*/
......@@ -400,34 +400,13 @@ function node_filter_line($text) {
*/
/*
** If HTML mark-up is being used, strip regular line breaks:
** When block tags are used, regular line breaks get stripped.
** However, when only text formatting tags are used, Drupal will
** insert linebreaks.
*/
if (strstr($text, "<br />") || strstr($text, "<p>")) {
$text = ereg_replace("[\r\n]", "", $text);
}
/*
** Replace '<br>', '<br />', '<p>' and '<p />' by '\n':
*/
$text = eregi_replace("<br />", "\n", $text);
$text = eregi_replace("<br />", "\n", $text);
$text = eregi_replace("<p>", "\n", $text);
$text = eregi_replace("<p />", "\n", $text);
/*
** Replace '\r\n' by '\n':
*/
$text = ereg_replace("\r\n", "\n", $text);
/*
** Replace some new line charachters:
*/
while (strpos($text, "\n\n\n")) {
$text = ereg_replace("\n\n\n", "\n\n", $text);
if (strip_tags($text, "<a><i><b><u><tt><code><cite><strong>") != $text) {
$text = ereg_replace("[\r\n]", "", $text);
}
/*
......@@ -732,7 +711,7 @@ function node_admin() {
print node_admin_edit($id);
break;
case t("Preview"):
$edit = node_validate($edit, $error);
$edit = object2array(node_validate($edit, $error));
print node_preview($edit);
break;
case t("Submit"):
......@@ -1088,27 +1067,29 @@ function node_preview($node, $error = NULL) {
** Apply the required filters:
*/
$node = object2array($node);
if ($node->nid) {
$node = array_merge($node, module_invoke($node->type, "save", "update", $node));
$view = array2object(array_merge(object2array($node), module_invoke($node->type, "save", "update", $node)));
}
else {
$node = array_merge($node, module_invoke($node->type, "save", "create", $node));
$view = array2object(array_merge(object2array($node), module_invoke($node->type, "save", "create", $node)));
}
$node = array2object($node);
/*
** Display a prenode of the node:
*/
if ($node->teaser && $node->teaser != $node->body) {
$view->body = filter($view->body);
$view->teaser = filter($view->teaser);
if ($view->teaser && $view->teaser != $view->body) {
print "<h3>". t("Preview full version") ."</h3>";
node_view($node, 0);
node_view($view, 0);
print "<h3>". t("Preview trimmed version") ."</h3>";
node_view($node, 1);
node_view($view, 1);
print "<p><i>". t("The trimmed version of your post shows how your post would look like when promoted to the main page or when exported for syndication. You can insert a delimiter '---' (without the quotes) to fine-tune where your post gets split. However note that delimiter will be ignored when misplaced.") ."</i></p>";
}
else {
node_view($node, 0);
node_view($view, 0);
}
return node_form($node, $error);
......
......@@ -78,19 +78,19 @@ function node_teaser($body) {
}
if ($length = strpos($body, "<br />", $size)) {
return substr($body, 0, $length + 1);
return substr($body, 0, $length + 6);
}
if ($length = strpos($body, "<br>", $size)) {
return substr($body, 0, $length + 1);
return substr($body, 0, $length + 4);
}
if ($length = strpos($body, "</p>", $size)) {
return substr($body, 0, $length + 1);
return substr($body, 0, $length + 4);
}
/*
** When even the first paragraph is too long, try to
** When even the first paragraph is too long, try to
** split at the end of the next sentence.
*/
......@@ -400,34 +400,13 @@ function node_filter_line($text) {
*/
/*
** If HTML mark-up is being used, strip regular line breaks:
** When block tags are used, regular line breaks get stripped.
** However, when only text formatting tags are used, Drupal will
** insert linebreaks.
*/
if (strstr($text, "<br />") || strstr($text, "<p>")) {
$text = ereg_replace("[\r\n]", "", $text);
}
/*
** Replace '<br>', '<br />', '<p>' and '<p />' by '\n':
*/
$text = eregi_replace("<br />", "\n", $text);
$text = eregi_replace("<br />", "\n", $text);
$text = eregi_replace("<p>", "\n", $text);
$text = eregi_replace("<p />", "\n", $text);
/*
** Replace '\r\n' by '\n':
*/
$text = ereg_replace("\r\n", "\n", $text);
/*
** Replace some new line charachters:
*/
while (strpos($text, "\n\n\n")) {
$text = ereg_replace("\n\n\n", "\n\n", $text);
if (strip_tags($text, "<a><i><b><u><tt><code><cite><strong>") != $text) {
$text = ereg_replace("[\r\n]", "", $text);
}
/*
......@@ -732,7 +711,7 @@ function node_admin() {
print node_admin_edit($id);
break;
case t("Preview"):
$edit = node_validate($edit, $error);
$edit = object2array(node_validate($edit, $error));
print node_preview($edit);
break;
case t("Submit"):
......@@ -1088,27 +1067,29 @@ function node_preview($node, $error = NULL) {
** Apply the required filters:
*/
$node = object2array($node);
if ($node->nid) {
$node = array_merge($node, module_invoke($node->type, "save", "update", $node));
$view = array2object(array_merge(object2array($node), module_invoke($node->type, "save", "update", $node)));
}
else {
$node = array_merge($node, module_invoke($node->type, "save", "create", $node));
$view = array2object(array_merge(object2array($node), module_invoke($node->type, "save", "create", $node)));
}
$node = array2object($node);
/*
** Display a prenode of the node:
*/
if ($node->teaser && $node->teaser != $node->body) {
$view->body = filter($view->body);
$view->teaser = filter($view->teaser);
if ($view->teaser && $view->teaser != $view->body) {
print "<h3>". t("Preview full version") ."</h3>";
node_view($node, 0);
node_view($view, 0);
print "<h3>". t("Preview trimmed version") ."</h3>";
node_view($node, 1);
node_view($view, 1);
print "<p><i>". t("The trimmed version of your post shows how your post would look like when promoted to the main page or when exported for syndication. You can insert a delimiter '---' (without the quotes) to fine-tune where your post gets split. However note that delimiter will be ignored when misplaced.") ."</i></p>";
}
else {
node_view($node, 0);
node_view($view, 0);
}
return node_form($node, $error);
......
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