Example #1
0
 public function testHTMLCleaningWithNonASCIIChars()
 {
     // this file is UTF-8 but odd comments are sent up looking like Windows-1252 so we need the
     // input text to be encoded thus otherwise the output is different
     $text = iconv('UTF-8', 'Windows-1252', "This is a curly  ’ apostrophe. Is 2 < 3 ø ø €  ’ « ö à");
     $this->assertEquals("This is a curly  ’ apostrophe. Is 2 < 3 ø ø €  ’ « ö à", prepare_comment_for_display($text));
 }
Example #2
0
            echo ">\n";
        }
        $USERURL = new URL('userview');
        $USERURL->insert(array('u' => $comment['user_id']));
        ?>
        <div class="comment">
            <p><a href="<?php 
        echo $USERURL->generate();
        ?>
" title="See information about this user"><strong><?php 
        echo _htmlentities($comment['firstname']) . ' ' . _htmlentities($comment['lastname']);
        ?>
</strong></a><br>
<?php 
        // Make URLs into links and do <br>s.
        $body = prepare_comment_for_display($comment['body']);
        // In utility.php
        echo $body;
        ?>
</p>

        </div>
        <div class="sidebar">
        <p> Posted on
<?php 
        list($date, $time) = explode(' ', $comment['posted']);
        $date = format_date($date, SHORTDATEFORMAT);
        $time = format_time($time, TIMEFORMAT);
        echo $date;
        ?>
,
Example #3
0
        $hansardtext = trim_characters($comment['hbody'], 0, 65);
        list($date, $time) = explode(' ', $comment['posted']);
        $date = format_date($date, SHORTDATEFORMAT);
        // Get the name of the member whose epobject was commented upon (if any).
        if (isset($comment['speaker']) && $comment['speaker']['first_name'] != '') {
            $member_name = $comment['speaker']['first_name'] . ' ' . $comment['speaker']['last_name'] . ': ';
        } else {
            $member_name = '';
        }
        $user_name = htmlentities($comment['firstname'] . ' ' . $comment['lastname']);
        // We're grouping things by epobject_id, so we're going to display the number
        // of comments on this epobject.
        $plural = $comment['total_comments'] == 1 ? ' comment' : ' comments';
        echo "\t\t\t\t<p><a href=\"{$comment['url']}\">{$comment['total_comments']}{$plural}</a> to <strong>" . $member_name . $hansardtext . "</strong><br>\n";
        echo "\t\t\t\t<small>(posted on {$date})</small><br>\n";
        echo "\t\t\t\t" . prepare_comment_for_display($comment['body']) . "</p>";
        ?>

<?php 
        $PAGE->stripe_end();
    }
    $PAGE->stripe_start();
    $PAGE->page_links($data);
    $PAGE->stripe_end();
} else {
    $PAGE->stripe_start();
    ?>
	<p>This user hasn't posted any comments.</p>
<?php 
    $PAGE->stripe_end();
}
Example #4
0
function generate_commentteaser (&$row, $major, $action_links) {
	// Returns HTML for the one fragment of comment and link for the sidebar.
	// $totalcomments is the number of comments this item has on it.
	// $comment is an array like:
	/* $comment = array (
		'comment_id' => 23,
		'user_id'	=> 34,
		'body'		=> 'Blah blah...',
		'posted'	=> '2004-02-24 23:45:30',
		'username'	=> 'phil'
		)
	*/
	// $url is the URL of the item's page, which contains comments.
	
	global $this_page, $THEUSER, $hansardmajors;
	
	$html = '';
	
        //Action links
    if (isset($action_links)) {
        $html .= '<ul>';
            foreach ($action_links as $action_link) {
				if (!is_array($action_link)) {
					$html .= $action_link;
					continue;
				}
                $html .= '<li>';
                $html .= '<a href="' . $action_link['link'] . '" class="' . $action_link['class'] . '"';
				if (isset($action_link['title'])) {
					$html .= ' title="' . $action_link['title'] . '"';
				}
                if (isset($action_link['onclick'])) {
                    $html .= ' onclick="' . $action_link['onclick']  . '"';
                }
                $html .= '>';
                $html .= $action_link["text"];                                    
                $html .= '</a>';
				if (isset($action_link['after']) && $action_link['after']) {
				    $html .= ' (' . $action_link['after'] . ')';
				}
                $html .= "</li>\n";
            }
        $html .= '</ul>';        
    }

	if ($hansardmajors[$major]['type'] == 'debate' && $hansardmajors[$major]['page_all']==$this_page) {

//		$html .= ' <a href="' .  $row['commentsurl'] . '" title="Copy this URL to link directly to this piece of text" class="permalink">Link to this</a>';
		
		// Build the 'Add an annotation' link.
		if (!$THEUSER->isloggedin()) {
			$URL = new URL('userprompt');
			$URL->insert(array('ret'=>$row['commentsurl']));
			$commentsurl = $URL->generate();
		} else {
			$commentsurl = $row['commentsurl'];
		}
		
		$html .= '<div class="add"><a class="annotate" href="' . $commentsurl . '#addcomment" title="Annotate this speech">Add an annotation</a> <small>(e.g. more info, blog post or wikipedia article)</small></div>';
		
		//Add existing annotations
		if ($row['totalcomments'] > 0) {
			$comment = $row['comment'];
			
			// If the comment is longer than the speech body, we want to trim it
			// to be the same length so they fit next to each other.
			// But the comment typeface is smaller, so we scale things slightly too...
			$targetsize = round(strlen($row['body']) * 0.6);
			
			if ($targetsize > strlen($comment['body'])) {
				// This comment will fit in its entirety.
				$commentbody = $comment['body'];

				if ($row['totalcomments'] > 1) {
					$morecount = $row['totalcomments'] - 1;
					$plural = $morecount == 1 ? 'annotation' : 'annotations';
					$linktext = "Read $morecount more $plural";
				}
				
			} else {
				// This comment needs trimming.
				$commentbody = trim_characters($comment['body'], 0, $targetsize, 1000);
				if ($row['totalcomments'] > 1) {
					$morecount = $row['totalcomments'] - 1;
					$plural = $morecount == 1 ? 'annotation' : 'annotations';
					$linktext = "Continue reading (and $morecount more $plural)";
				} else {
					$linktext = 'Continue reading';
				}
			}

			$html .= '<blockquote><p>' . prepare_comment_for_display($commentbody) . '</p><cite>Submitted by ' . htmlentities($comment['username']) . '</cite></small></blockquote>' ;
			
			if (isset($linktext)) {
				$html .= ' <a class="morecomments" href="' . $row['commentsurl'] . '#c' . $comment['comment_id'] . '" title="See any annotations posted about this">' . $linktext . '</a>';
			}
			
		}


	}
	$html = "\t\t\t\t" . '<div class="comment-teaser">' . $html . "</div>\n";
	
	return $html;
}
Example #5
0
function generate_commentteaser(&$row, $major)
{
    // Returns HTML for the one fragment of comment and link for the sidebar.
    // $totalcomments is the number of comments this item has on it.
    // $comment is an array like:
    /* $comment = array (
    		'comment_id' => 23,
    		'user_id'	=> 34,
    		'body'		=> 'Blah blah...',
    		'posted'	=> '2004-02-24 23:45:30',
    		'username'	=> 'phil'
    		)
    	*/
    // $url is the URL of the item's page, which contains comments.
    global $this_page, $THEUSER, $hansardmajors;
    $html = '';
    if ($hansardmajors[$major]['type'] == 'debate' && $hansardmajors[$major]['page_all'] == $this_page) {
        if ($row['totalcomments'] > 0) {
            $comment = $row['comment'];
            // If the comment is longer than the speech body, we want to trim it
            // to be the same length so they fit next to each other.
            // But the comment typeface is smaller, so we scale things slightly too...
            $targetsize = round(strlen($row['body']) * 0.6);
            if ($targetsize > strlen($comment['body'])) {
                // This comment will fit in its entirety.
                $commentbody = $comment['body'];
                if ($row['totalcomments'] > 1) {
                    $morecount = $row['totalcomments'] - 1;
                    $plural = $morecount == 1 ? 'comment' : 'comments';
                    $linktext = "Read {$morecount} more {$plural}";
                }
            } else {
                // This comment needs trimming.
                $commentbody = htmlentities(trim_characters($comment['body'], 0, $targetsize));
                if ($row['totalcomments'] > 1) {
                    $morecount = $row['totalcomments'] - 1;
                    $plural = $morecount == 1 ? 'comment' : 'comments';
                    $linktext = "Continue reading (and {$morecount} more {$plural})";
                } else {
                    $linktext = 'Continue reading';
                }
            }
            $html = '<em>' . htmlentities($comment['username']) . '</em>: ' . prepare_comment_for_display($commentbody);
            if (isset($linktext)) {
                $html .= ' <a href="' . $row['commentsurl'] . '#c' . $comment['comment_id'] . '" title="See any comments posted about this">' . $linktext . '</a>';
            }
            $html .= '<br><br>';
        }
        // 'Add a comment' link.
        if (!$THEUSER->isloggedin()) {
            $URL = new URL('userprompt');
            $URL->insert(array('ret' => $row['commentsurl']));
            $commentsurl = $URL->generate();
        } else {
            $commentsurl = $row['commentsurl'];
        }
        $html .= '<a href="' . $commentsurl . '#addcomment" title="Comment on this"><strong>Add your comment</strong></a>';
        $html = "\t\t\t\t" . '<p class="comment-teaser">' . $html . "</p>\n";
    }
    return $html;
}
 function generate_commentteaser($row)
 {
     // Returns HTML for the one fragment of comment and link for the sidebar.
     // $totalcomments is the number of comments this item has on it.
     // $comment is an array like:
     /* $comment = array (
            'comment_id' => 23,
            'user_id'    => 34,
            'body'        => 'Blah blah...',
            'posted'    => '2004-02-24 23:45:30',
            'username'    => 'phil'
            )
        */
     // $url is the URL of the item's page, which contains comments.
     if ($row['totalcomments'] == 0) {
         return;
     }
     //Add existing annotations
     $comment = $row['comment'];
     // If the comment is longer than the speech body, we want to trim it
     // to be the same length so they fit next to each other.
     // But the comment typeface is smaller, so we scale things slightly too...
     $targetsize = round(strlen($row['body']) * 0.6);
     $linktext = '';
     if ($targetsize > strlen($comment['body'])) {
         // This comment will fit in its entirety.
         $commentbody = $comment['body'];
         if ($row['totalcomments'] > 1) {
             $morecount = $row['totalcomments'] - 1;
             $plural = $morecount == 1 ? 'annotation' : 'annotations';
             $linktext = "Read {$morecount} more {$plural}";
         }
     } else {
         // This comment needs trimming.
         $commentbody = trim_characters($comment['body'], 0, $targetsize, 1000);
         if ($row['totalcomments'] > 1) {
             $morecount = $row['totalcomments'] - 1;
             $plural = $morecount == 1 ? 'annotation' : 'annotations';
             $linktext = "Continue reading (and {$morecount} more {$plural})";
         } else {
             $linktext = 'Continue reading';
         }
     }
     return array('body' => prepare_comment_for_display($commentbody), 'username' => _htmlentities($comment['username']), 'linktext' => $linktext, 'commentsurl' => $row['commentsurl'], 'comment_id' => $comment['comment_id']);
 }