Commit 5fb307f5 authored by Dries's avatar Dries

- refactoring, refactoring, refactoring
parent 5b92e909
......@@ -2,7 +2,6 @@
$na = "<I>na</I>";
function check_textfield($message) {
return strip_tags(str_replace("\"", "&quot;", stripslashes($message)));
}
......@@ -17,7 +16,8 @@ function check_export($message) {
function check_textarea($message) {
global $allowed_html;
return htmlspecialchars(strip_tags(stripslashes($message), $allowed_html));
return strip_tags(stripslashes($message), $allowed_html);
// return htmlspecialchars(strip_tags(stripslashes($message), $allowed_html));
}
function check_input($message) {
......@@ -102,9 +102,9 @@ function format_tag($link, $text) {
function format_text($text) {
$src = array("/(<\/?)(\w+)([^>]*>)/e", // convert HTML to lower case
$src = array( // "/(<\/?)(\w+)([^>]*>)/e", // convert HTML to lower case
"/\[(([^\|]*?)(\|([^\|]*?))?)\]/e"); // [link|description]
$dst = array("'\\1'. strtolower('\\2') .'\\3'", // convert HTML to lower case
$dst = array( // "'\\1'. strtolower('\\2') .'\\3'", // convert HTML to lower case
format_tag('\\2', '\\4')); // [link|description]
return preg_replace($src, $dst, $text);
......
......@@ -31,7 +31,7 @@ $comment_votes = array("none" => "none",
#
# Allowed HTML tags:
#
$allowed_html = "<A><B><BLOCKQUOTE><DD><DL><DT><EM><HR><I><LI><SMALL><OL><U><UL>";
$allowed_html = "<A><B><BLOCKQUOTE><CODE><DD><DL><DT><EM><HR><I><LI><SMALL><OL><U><UL>";
#
# Name for anonymous users:
......
......@@ -109,7 +109,7 @@ function theme_moderation_results($theme, $node) {
$output .= format_username($account->userid) ." voted '". user_get($account, "history", "n$node->nid") ."'.<BR>";
}
$theme->box(t("Moderation results"), ($output ? $output : t("This story has not been moderated yet.")));
$theme->box(t("Moderation results"), ($output ? $output : t("This node has not been moderated yet.")));
}
}
......
......@@ -75,6 +75,16 @@ function book_search() {
print search_data($keys, $mod);
}
function book_toc($parent = 0, $offset = 0, $toc = array()) {
global $status;
$result = db_query("SELECT n.*, b.* FROM nodes n LEFT JOIN book b ON n.nid = b.node WHERE n.type = 'book' AND n.status = '$status[posted]' AND b.parent = '$parent' ORDER BY b.weight");
while ($node = db_fetch_object($result)) {
$toc[$node->nid] = ($offset ? $offset : "") ."". ++$number .". $node->title";
$toc = book_toc($node->nid, ($offset ? "$offset." : "") ."$number.", $toc);
}
return $toc;
}
function book_form($edit = array()) {
global $allowed_html, $PHP_SELF, $REQUEST_URI, $status, $theme, $user;
......@@ -92,8 +102,7 @@ function book_form($edit = array()) {
}
else {
$output .= "<B>". t("Parent") .":</B><BR>\n";
$result = db_query("SELECT nid, title FROM nodes WHERE type = 'book' AND status = '$status[posted]'");
while ($node = db_fetch_object($result)) $options2 .= "<OPTION VALUE=\"$node->nid\"". ($edit[parent] == $node->nid ? " SELECTED" : "") .">". check_select($node->title) ."</OPTION>";
foreach (book_toc() as $key=>$value) $options2 .= "<OPTION VALUE=\"$key\"". ($edit[parent] == $key ? " SELECTED" : "") .">". check_select($value) ."</OPTION>";
if (user_access($user, "book")) $options2 .= "<OPTION VALUE=\"0\"". ($edit[parent] == 0 ? " SELECTED" : "") .">&nbsp;</OPTION>";
$output .= "<SELECT NAME=\"edit[parent]\">$options2</SELECT><BR>\n";
$output .= "<SMALL><I>". t("The parent subject or category the new page belongs in.") ."</I></SMALL><P>\n";
......
......@@ -75,6 +75,16 @@ function book_search() {
print search_data($keys, $mod);
}
function book_toc($parent = 0, $offset = 0, $toc = array()) {
global $status;
$result = db_query("SELECT n.*, b.* FROM nodes n LEFT JOIN book b ON n.nid = b.node WHERE n.type = 'book' AND n.status = '$status[posted]' AND b.parent = '$parent' ORDER BY b.weight");
while ($node = db_fetch_object($result)) {
$toc[$node->nid] = ($offset ? $offset : "") ."". ++$number .". $node->title";
$toc = book_toc($node->nid, ($offset ? "$offset." : "") ."$number.", $toc);
}
return $toc;
}
function book_form($edit = array()) {
global $allowed_html, $PHP_SELF, $REQUEST_URI, $status, $theme, $user;
......@@ -92,8 +102,7 @@ function book_form($edit = array()) {
}
else {
$output .= "<B>". t("Parent") .":</B><BR>\n";
$result = db_query("SELECT nid, title FROM nodes WHERE type = 'book' AND status = '$status[posted]'");
while ($node = db_fetch_object($result)) $options2 .= "<OPTION VALUE=\"$node->nid\"". ($edit[parent] == $node->nid ? " SELECTED" : "") .">". check_select($node->title) ."</OPTION>";
foreach (book_toc() as $key=>$value) $options2 .= "<OPTION VALUE=\"$key\"". ($edit[parent] == $key ? " SELECTED" : "") .">". check_select($value) ."</OPTION>";
if (user_access($user, "book")) $options2 .= "<OPTION VALUE=\"0\"". ($edit[parent] == 0 ? " SELECTED" : "") .">&nbsp;</OPTION>";
$output .= "<SELECT NAME=\"edit[parent]\">$options2</SELECT><BR>\n";
$output .= "<SMALL><I>". t("The parent subject or category the new page belongs in.") ."</I></SMALL><P>\n";
......
......@@ -212,7 +212,7 @@ function headline_export($uri) {
while ($node = db_fetch_object($result)) {
print "<item>\n";
print " <title>". check_export($node->title) ."</title>\n";
print " <link>". $site_url ."node.php?id=$node->id</link>\n";
print " <link>". $site_url ."node.php?id=$node->nid</link>\n";
print "</item>\n";
}
......
......@@ -77,7 +77,7 @@ function moderation_node($id) {
else {
if ($node->pid && $n = node_get_object("nid", $node->pid)) {
if ($node->pid) $output .= " ". t("The above node is a suggested update for an existing node:") ." \"<A HREF=\"node.php?id=$n->nid\">". check_output($n->title) ."</A>\".";
if ($node->log) $output .= " ". t("The log message to accompany this update is given below:") ."<P>". check_output($node->log, 1) ."</P>";
if ($node->log) $output .= " ". t("The log message to accompany this update is given below:") ."<P><I>". check_output($node->log, 1) ."</I></P>";
}
// moderation form:
......
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