diff -r 540d077b7612 -r 66b299fdb9ca plugins/Newsboy.php
--- a/plugins/Newsboy.php Fri Sep 28 23:49:56 2007 -0400
+++ b/plugins/Newsboy.php Mon Jan 21 10:39:25 2008 -0500
@@ -286,9 +286,12 @@
if ( $s )
{
$stuff = RenderMan::strToPageID($s);
+ // Hackish fix to prevent the categorization button and other stuff from being displayed
+ $paths->pages[$s]['special'] = 1;
$page = new PageProcessor($stuff[0], $stuff[1]);
- $page->send();
- echo $p;
+ $content = $page->fetch_text();
+ $content = '?>' . RenderMan::render($content);
+ eval($content);
}
echo '
Latest news
';
@@ -319,15 +322,30 @@
{
if ( $i < 5 )
{
+ $content = $row['page_text'];
+
+ $trimmed = false;
+ if ( $pos = strpos($content, '' ) )
+ {
+ $content = substr($content, 0, $pos);
+ $trimmed = true;
+ }
+
$title = htmlspecialchars($row['name']);
- $content = RenderMan::render($row['page_text']);
- if ( strlen($content) > 400 )
+ $content = RenderMan::render($content);
+
+ if ( strlen($content) > 400 && !$trimmed )
{
$content = nb_trim_paragraph($content, 400, $trimmed);
}
if ( $trimmed )
{
- $content .= ' Read more...';
+ $link = ' Read more...';
+ $content = preg_replace('/(.+?)<\/(p|ul|table|div|pre)>([\s]*?)$/Usi', '\\1' . $link . '\\2>\\3', $content, 1);
+ if ( !strstr($content, $link) )
+ {
+ $content .= $link;
+ }
}
$user_link = nb_make_username_link($row['author'], $row['user_level']);
$date = date('F d, Y h:i:s a', $row['urlname']);
@@ -364,12 +382,13 @@
';
}
+ show_category_info();
}
/**
@@ -773,7 +792,7 @@
$errors[] = 'Invalid second.';
$name = $_POST['article_name'];
- $name = $db->escape($name);
+ // This is db-escaped by PageUtils
$author = $_POST['author'];
$author = $db->escape($author);
@@ -789,19 +808,27 @@
if ( count($errors) < 1 )
{
$publ = ( isset($_POST['published']) ) ? 1 : 0;
+
$result = PageUtils::createpage( (string)$time, 'NewsBoy', $name, $publ );
- // Set content
- $content = RenderMan::preprocess_text($_POST['content'], true); // this also SQL-escapes it
-
- $q = $db->sql_query('UPDATE '.table_prefix.'page_text SET page_text=\'' . $content . '\' WHERE page_id=\'' . $time . '\' AND namespace=\'NewsBoy\';');
- if ( !$q )
- $db->_die();
-
- if ( $result )
- echo 'Your changes have been saved.
';
+ if ( $result == 'good' )
+ {
+ // Set content
+ $content = RenderMan::preprocess_text($_POST['content'], true); // this also SQL-escapes it
+
+ $q = $db->sql_query('UPDATE '.table_prefix.'page_text SET page_text=\'' . $content . '\' WHERE page_id=\'' . $time . '\' AND namespace=\'NewsBoy\';');
+ if ( !$q )
+ $db->_die();
+
+ if ( $result )
+ echo 'Your changes have been saved.
';
+ else
+ $errors[] = 'PageUtils::createpage returned an error.';
+ }
else
- $errors[] = 'PageUtils::createpage returned an error.';
+ {
+ $errors[] = 'PageUtils::createpage returned an error: ' . htmlspecialchars($result);
+ }
break;
}
@@ -810,7 +837,7 @@
if ( count($errors) > 0 )
echo 'Errors encountered while preparing data:
- ' . implode('
- ', $errors) . '
';
- $time = time();;
+ $time = time();
// Get author
$author = $session->username;
@@ -826,7 +853,7 @@
$minute = date('m', $time);
$second = date('s', $time);
- echo '