[geeklog-cvs] geeklog-1.3/public_html comment.php,1.44,1.45 lib-common.php,1.244,1.245
geeklog-cvs-admin at lists.geeklog.net
geeklog-cvs-admin at lists.geeklog.net
Sun Aug 17 05:38:03 EDT 2003
- Previous message (by thread): [geeklog-cvs] geeklog-1.3/public_html/layout/Classic/comment comment.thtml,NONE,1.1 thread.thtml,NONE,1.1 startcomment.thtml,1.1,1.2
- Next message (by thread): [geeklog-cvs] geeklog-1.3/public_html/layout/Digital_Monochrome/comment comment.thtml,NONE,1.1 thread.thtml,NONE,1.1 startcomment.thtml,1.1,1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /usr/cvs/geeklog/geeklog-1.3/public_html
In directory geeklog_prod:/tmp/cvs-serv32401/public_html
Modified Files:
comment.php lib-common.php
Log Message:
Integrated Vincent Furia's new comment code to use templates for comments.
Index: comment.php
===================================================================
RCS file: /usr/cvs/geeklog/geeklog-1.3/public_html/comment.php,v
retrieving revision 1.44
retrieving revision 1.45
diff -C2 -d -r1.44 -r1.45
*** comment.php 25 Jun 2003 08:39:02 -0000 1.44
--- comment.php 17 Aug 2003 09:38:01 -0000 1.45
***************
*** 140,152 ****
if ($mode == $LANG03[14] && !empty($title) && !empty($comment) ) {
$start = new Template( $_CONF['path_layout'] . 'comment' );
! $start->set_file( array( 'startcomment' => 'startcomment.thtml' ));
$start->set_var( 'site_url', $_CONF['site_url'] );
$start->set_var( 'layout_url', $_CONF['layout_url'] );
! $thecomments = COM_comment ($HTTP_POST_VARS, 1, $type, 0,
! 'flat', true);
$start->set_var( 'comments', $thecomments );
! $retval .= $start->finish( $start->parse( 'output', 'startcomment' ));
} else if ($mode == $LANG03[14]) {
$retval .= COM_startBlock ($LANG03[17], '',
--- 140,154 ----
if ($mode == $LANG03[14] && !empty($title) && !empty($comment) ) {
$start = new Template( $_CONF['path_layout'] . 'comment' );
! $start->set_file( array( 'comment' => 'startcomment.thtml' ));
$start->set_var( 'site_url', $_CONF['site_url'] );
$start->set_var( 'layout_url', $_CONF['layout_url'] );
! $thecomments = COM_getComment ($HTTP_POST_VARS, 'flat', $type,
! 'ASC', true );
$start->set_var( 'comments', $thecomments );
! $retval .= COM_startBlock ($LANG03[14])
! . $start->finish( $start->parse( 'output', 'comment' ))
! . COM_endBlock ();
} else if ($mode == $LANG03[14]) {
$retval .= COM_startBlock ($LANG03[17], '',
Index: lib-common.php
===================================================================
RCS file: /usr/cvs/geeklog/geeklog-1.3/public_html/lib-common.php,v
retrieving revision 1.244
retrieving revision 1.245
diff -C2 -d -r1.244 -r1.245
*** lib-common.php 12 Aug 2003 21:10:04 -0000 1.244
--- lib-common.php 17 Aug 2003 09:38:01 -0000 1.245
***************
*** 1113,1117 ****
if( $A[0] == $selected )
{
! $retval .= ' selected';
}
--- 1113,1117 ----
if( $A[0] == $selected )
{
! $retval .= ' selected="selected"';
}
***************
*** 2472,2649 ****
/**
! * This function displays the comments in a high level format.
! *
! * Begins displaying user comments for an item
! *
! * @param string $sid ID for item to show comments for
! * @param string $title Title of item
! * @param string $type Type of item (article,photo,link,etc.)
! * @param string $order How to order the comments 'ASC' or 'DESC'
! * @param string $mode comment mode (nested, flat, etc.)
! * @param int $pid Parent ID
! * @see function COM_commentBar
! * @see function COM_commentChildren
! * @return string HTML Formated Comments
*
*/
! function COM_userComments( $sid, $title, $type='article', $order='', $mode='', $pid=0 )
{
! global $_TABLES, $_CONF, $LANG01, $_USER;
! if( !empty( $_USER['uid'] ) && empty( $order ) && empty( $mode ))
{
! $result = DB_query( "SELECT commentorder,commentmode,commentlimit FROM {$_TABLES['usercomment']} WHERE uid = '{$_USER['uid']}'" );
! $U = DB_fetchArray( $result );
! $order = $U['commentorder'];
! $mode = $U['commentmode'];
! $limit = $U['commentlimit'];
}
! if( empty( $order ))
{
! $order = 'ASC';
! }
! if( empty( $mode ))
{
! $mode = $_CONF['comment_mode'];
}
!
! if( empty( $limit ))
{
! $limit = $_CONF['comment_limit'];
}
!
! if( $mode == 'nocomments' )
{
! $retval .= COM_commentBar( $sid, $title, $type, $order, $mode );
}
else
{
! $comment = new Template( $_CONF['path_layout'] . 'comment' );
! $comment->set_file( array( 'startcomment' => 'startcomment.thtml' ));
! $comment->set_var( 'site_url', $_CONF['site_url'] );
! $comment->set_var( 'layout_url', $_CONF['layout_url'] );
!
! $thecomments = '';
! switch( $mode )
! {
! case 'nested':
! {
! $result = DB_query( "SELECT *,unix_timestamp(date) AS nice_date FROM {$_TABLES['comments']} WHERE sid = '$sid' AND pid = 0 AND type = '$type' ORDER BY date $order LIMIT $limit" );
! $nrows = DB_numRows( $result );
! $retval .= COM_commentBar( $sid, $title, $type, $order, $mode );
!
! if( $nrows > 0 )
! {
! for( $i = 0; $i < $nrows; $i++ )
! {
! $A = DB_fetchArray( $result );
! $thecomments .= COM_comment( $A, 0, $type, 0, $mode );
! $thecomments .= COM_commentChildren( $sid, $A['cid'], $order, $mode, $type );
! }
! }
! else
! {
! $thecomments .= '<tr><td class="commenttitle" align="center">' . $LANG01[29] . '</td></tr>';
! }
! }
! break;
!
! case 'flat':
! {
! $result = DB_query( "SELECT *,unix_timestamp(date) AS nice_date FROM {$_TABLES['comments']} WHERE sid = '$sid' AND type = '$type' ORDER BY date $order LIMIT $limit" );
! $nrows = DB_numRows( $result );
! $retval .= COM_commentBar( $sid, $title, $type, $order, $mode );
! if( $nrows > 0 )
! {
! for( $i =0; $i < $nrows; $i++ )
! {
! $A = DB_fetchArray( $result );
! $thecomments .= COM_comment( $A, 0 ,$type, 0, $mode );
! }
! }
! else
! {
! $thecomments .= '<tr><td class="commenttitle" align="center">' . $LANG01[29] . '</td></tr>';
! }
! }
! break;
! case 'threaded':
! {
! $result = DB_query( "SELECT *,unix_timestamp(date) AS nice_date FROM {$_TABLES['comments']} WHERE sid = '$sid' AND pid = $pid AND type = '$type' ORDER BY date $order LIMIT $limit" );
! $nrows = DB_numRows( $result );
! $retval .= COM_commentBar( $sid, $title, $type, $order, $mode );
! if( $nrows > 0 )
! {
! for( $i = 0; $i < $nrows; $i++ )
! {
! $A = DB_fetchArray( $result );
! $thecomments .= COM_comment( $A, 0, $type, 0, $mode)
! . '<tr><td>'
! . COM_commentChildren( $sid, $A['cid'], $order, $mode, $type )
! . '</td></tr>';
! }
! }
! else
! {
! $thecomments .= '<tr><td class="commenttitle" align="center">' . $LANG01[29] . '</td></tr>';
! }
! }
! break;
}
-
- $comment->set_var( 'comments', $thecomments );
- $retval .= $comment->finish( $comment->parse( 'output', 'startcomment' ));
}
! return $retval;
! }
!
! /**
! * Prints the next level of children for a given comment
! *
! * This is called recursivley to display all the comments for a given
! * comment
! *
! * @param string $sid ID for item comments belong to
! * @param string $pid Parent ID
! * @param string $order Order to show comments in 'ASC' or 'DESC'
! * @param string $mode Mode (e.g. nested, flat, etc)
! * @param string $type Type of item (article, photo, link, etc.)
! * @param int $level How deep in comment thread we are
! * @see COM_commentBar
! * @see COM_userComments
! *
! */
!
! function COM_commentChildren( $sid, $pid, $order, $mode, $type, $level=0 )
! {
! global $_TABLES, $_CONF;
!
! $result = DB_query( "SELECT *,unix_timestamp(date) AS nice_date FROM {$_TABLES['comments']} WHERE sid = '$sid' AND pid = $pid ORDER BY date $order" );
! $nrows = DB_numRows( $result );
! if( $nrows > 0 )
{
! if( $mode == 'threaded' )
! {
! $retval .= '<ul>';
! }
! for( $i = 0; $i < $nrows; $i++ )
! {
! $A = DB_fetchArray( $result );
! $retval .= COM_comment( $A, 0, $type, $level + 1, $mode)
! . COM_commentChildren( $sid, $A['cid'], $order, $mode, $type, $level + 1 );
! }
! if( $mode == 'threaded' )
{
! $retval .= '</ul>';
}
}
--- 2472,2609 ----
/**
! * This function prints $A (an individual comment) in comment format
! *
! * @param array $A Associative array based on comment record
! * @param string $mode 'flat', 'threaded', etc
! * @param string $type Type of item (article, poll, etc.)
! * @param string $order How to order the comments 'ASC' or 'DESC'
! * @param boolean $preview Preview display (for edit) or not
! * @return string HTML Formated Comment
*
*/
! function COM_getComment( $A, $mode, $type, $order, $preview = false )
{
! global $_CONF, $_TABLES, $LANG01, $query;
! static $template;
! static $indent = 0;
!
! if( !isset( $_CONF['comment_indent'] ))
{
! $_CONF['comment_indent'] = 25;
}
! if( !isset( $template ))
{
! $template = new Template( $_CONF['path_layout'] . 'comment' );
! $template->set_file( array( 'comment' => 'comment.thtml',
! 'thread' => 'thread.thtml' ));
! // general variables
! $template->set_var( 'site_url', $_CONF['site_url'] );
! $template->set_var( 'layout_url', $_CONF['layout_url'] );
!
! $template->set_var( 'lang_replytothis', $LANG01[43] );
! $template->set_var( 'lang_reply', $LANG01[25] );
! $template->set_var( 'lang_authoredby', $LANG01[42] );
! $template->set_var( 'lang_on', $LANG01[36] );
! }
!
! // comment variables
! $template->set_var( 'indent', $indent );
! $template->set_var( 'pid', $A['cid'] );
! $template->set_var( 'author', $A['username'] );
! $template->set_var( 'author_id', $A['uid'] );
! if( $A['uid'] > 1 )
{
! $template->set_var( 'start_author_anchortag', '<a href="'
! . $_CONF['site_url'] . '/users.php?mode?profile&uid='
! . $A['uid'] . '">' );
! $template->set_var( 'end_author_anchortag', '</a>' );
}
! else
{
! $template->set_var( 'start_author_anchortag', '' );
! $template->set_var( 'end_author_anchortag', '' );
}
! if( $preview )
{
! $template->set_var( 'hide_if_preview', 'style="display:none"' );
}
else
{
! $template->set_var( 'hide_if_preview', '' );
! }
! if( empty( $A['nice_date'] ))
! {
! $A['nice_date'] = time ();
! }
! $template->set_var( 'date', strftime( $_CONF['date'], $A['nice_date'] ));
! $template->set_var( 'sid', $A['sid'] );
! $template->set_var( 'type', $A['type'] );
! if( $preview )
! {
! $template->set_var( 'delete_option', '' );
! }
! // NOTE: the following check is nonsense (but fully 1.3.8 compatible ;-)
! else if( SEC_hasAccess( $A['owner_id'], $A['group_id'], $A['perm_owner'],
! $A['perm_group'], $A['perm_members'], $A['perm_anon'] ) == 3 )
! {
! $template->set_var( 'delete_option', '| <a href="' . $_CONF['site_url']
! . '/comment.php?mode=' . $LANG01[28] . '&cid=' . $A['cid']
! . '&sid=' . $A['sid'] . '&type=' . $type . '">'
! . $LANG01[28] . '</a> ' );
! }
! $A['title'] = stripslashes( $A['title'] );
! $A['title'] = str_replace( '$', '$', $A['title'] );
! // and finally: format the actual text of the comment
! $A['comment'] = stripslashes( $A['comment'] );
! if( preg_match( '/<.*>/', $A['comment'] ) == 0 )
! {
! $A['comment'] = nl2br( $A['comment'] );
! }
! if( !empty( $query ))
! {
! $mywords = explode( ' ', $query );
! foreach( $mywords as $searchword )
! {
! $A['comment'] = preg_replace( "/(\>(((?>[^><]+)|(?R))*)\<)/ie", "preg_replace('/(?>$searchword+)/i','<span class=\"highlight\">$searchword</span>','\\0')", "<x>" . $A['comment'] . "<x>" );
}
}
+ $A['comment'] = str_replace( '$', '$', $A['comment'] );
+ $A['comment'] = str_replace( '{', '{', $A['comment'] );
+ $A['comment'] = str_replace( '}', '}', $A['comment'] );
! $template->set_var( 'title', $A['title'] );
! $template->set_var( 'comments', $A['comment'] );
! if( $mode == 'threaded' && $indent > 0 )
{
! $retval = $template->parse( 'output', 'thread' );
! }
! else
! {
! $retval = $template->parse( 'output', 'comment' );
! }
! if( !$preview && ( $mode == 'nested' || $mode == 'threaded' ))
! {
! $indent += $_CONF['comment_indent'];
! // get children
! $q = "SELECT c.*,u.username,unix_timestamp(c.date) AS nice_date "
! . "FROM {$_TABLES['comments']} AS c, {$_TABLES['users']} AS u "
! . "WHERE c.uid = u.uid AND sid = '{$A['sid']}' AND pid = {$A['cid']} "
! . "ORDER BY date $order";
! $result = DB_query( $q );
! while( $A = DB_fetchArray( $result ))
{
! $retval .= COM_getComment( $A, $mode, $type, $order );
}
+
+ $indent -= $_CONF['comment_indent'];
}
***************
*** 2652,2779 ****
/**
! * This function prints $A (an individual comment) in comment format
*
! * @param array $A Associative array based on comment record from DB
! * @param string $mode 'flat', 'threaded', etc
! * @param int $level how deep in comment thread
! * @param string $mode WTF? This can't be used twice!?!
! * @param boolean $ispreview Preview display (for edit) or not
! * @return string HTML Formated Comment
*
*/
!
! function COM_comment( $A, $mode=0, $type, $level=0, $mode='flat', $ispreview=false )
{
! global $_TABLES, $_CONF, $LANG01, $_USER, $order, $query;
!
! $level = $level * 25;
! // if no date, make it now!
! if( empty( $A['nice_date'] ))
{
! $A['nice_date'] = time();
}
! $A['title'] = stripslashes( $A['title'] );
!
! if( $mode == 'threaded' && $level > 0 )
{
! $retval .= '<li><b><a href="' . $_CONF['site_url'] . '/comment.php?mode=display&sid=' . $A['sid']
! . '&title=' . urlencode( $A['title'] ) . '&type=' . $type . '&order=' . $order . '&pid=' . $A['pid'].'">'
! . $A['title'] . '</a></b> - ' . $LANG01[42] . ' ';
!
! if( $A['uid'] == 1 )
! {
! $retval .= $LANG01[24];
! }
! else
! {
! $retval .= '<a href="' . $_CONF['site_url'] . '/users.php?mode=profile&uid=' . $A['uid'] . '">'
! . DB_getItem( $_TABLES['users'], 'username', "uid = '{$A['uid']}'" ) . '</a>';
! }
!
! $A['nice_date'] = strftime( $_CONF['date'], $A['nice_date'] );
! $retval .= ' ' . $LANG01[36] . ' ' . $A['nice_date'] . LB;
}
- else
- {
- if( $level > 0 )
- {
- $retval .= '<tr><td><table border="0" cellpadding="0" cellspacing="0" width="100%">' . LB
- . '<tr><td rowspan="3" width="' . $level . '"><img src="' . $_CONF['site_url']
- . '/images/speck.gif" width="' . $level . '" height="100%" alt=""></td>' . LB;
- }
- else
- {
- $retval .= '<tr>';
- }
! if( !empty( $query ))
! {
! $mywords = explode( ' ', $query );
! foreach( $mywords as $searchword )
! {
! $A['comment'] = preg_replace( "/(\>(((?>[^><]+)|(?R))*)\<)/ie", "preg_replace('/(?>$searchword+)/i','<span class=\"highlight\">$searchword</span>','\\0')", "<x>" . $A['comment'] . "<x>" );
! }
! }
! $A['title'] = str_replace( '$', '$', $A['title'] );
! $A['comment'] = str_replace( '$', '$', $A['comment'] );
! $A['comment'] = str_replace( '{', '{', $A['comment'] );
! $A['comment'] = str_replace( '}', '}', $A['comment'] );
! $retval .= '<td class="commenttitle">' . stripslashes( $A['title'] ) . '</td></tr>' . LB
! . '<tr><td>' . $LANG01[42] . ' ';
! if( $A['uid'] == 1 )
! {
! $retval .= $LANG01[24];
! }
! else
{
! $retval .= '<a href="' . $_CONF['site_url'] . '/users.php?mode=profile&uid=' . $A['uid'] . '">'
! . DB_getItem( $_TABLES['users'], 'username', "uid = '{$A['uid']}'" ) .'</a>';
! }
! $A['nice_date'] = strftime( $_CONF['date'], $A['nice_date'] );
! $comment = stripslashes( $A['comment'] );
! if( preg_match( '/<.*>/', $comment ) == 0 )
! {
! $comment = nl2br( $comment );
}
- $retval .= ' ' . $LANG01[36] . ' ' . $A['nice_date'] . '</td></tr>' . LB
- . '<tr><td valign="top">' . $comment;
! if( $mode == 0 && $ispreview == false )
{
! $retval .= '<p>[ <a href="' . $_CONF['site_url'] . '/comment.php?sid=' . $A['sid'] . '&pid='
! . $A['cid'] . '&title=' . rawurlencode( $A['title'] ) . '&type=' . $type . '">' . $LANG01[43]
! . '</a> ';
!
! // Until I find a better way to parent, we're stuck with this...
! if( $mode == 'threaded' && $A['pid'] != 0 )
! {
! $result = DB_query( "SELECT title,pid from {$_TABLES['comments']} where cid = '{$A['pid']}'" );
! $P = DB_fetchArray( $result );
! $retval .= '| <a href="' . $_CONF['site_url'] . '/comment.php?mode=display&sid=' . $A['sid']
! . '&title=' . rawurlencode( $P['title'] ) . '&type=' . $type . '&order=' . $order . '&pid='
! . $P['pid'] . '">' . $LANG01[44] . '</a> ';
! }
!
! if( SEC_hasAccess( $A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon'] ) == 3 )
! {
! $retval .= '| <a href="' . $_CONF['site_url'] . '/comment.php?mode=' . $LANG01[28] . '&cid='
! . $A['cid'] . '&sid=' . $A['sid'] . '&type=' . $type . '">' . $LANG01[28] . '</a> ';
! }
!
! $retval .= ']<br>';
}
! $retval .= '</td></tr>' . LB;
!
! if( $level > 0 )
! {
! $retval .= '</table></td></tr>' . LB;
! }
}
--- 2612,2696 ----
/**
! * This function displays the comments in a high level format.
*
! * Begins displaying user comments for an item
! *
! * @param string $sid ID for item to show comments for
! * @param string $title Title of item
! * @param string $type Type of item (article, poll, etc.)
! * @param string $order How to order the comments 'ASC' or 'DESC'
! * @param string $mode comment mode (nested, flat, etc.)
! * @param int $pid Parent ID
! * @see function COM_commentBar
! * @see function COM_commentChildren
! * @return string HTML Formated Comments
*
*/
! function COM_userComments( $sid, $title, $type='article', $order='', $mode='', $pid=0 )
{
! global $_CONF, $_TABLES, $_USER, $LANG01;
! if( !empty( $_USER['uid'] ) && empty( $order ) && empty( $mode ))
{
! $result = DB_query( "SELECT commentorder,commentmode,commentlimit FROM {$_TABLES['usercomment']} WHERE uid = '{$_USER['uid']}'" );
! $U = DB_fetchArray( $result );
! $order = $U['commentorder'];
! $mode = $U['commentmode'];
! $limit = $U['commentlimit'];
}
! if( empty( $order ))
{
! $order = 'ASC';
}
! if( empty( $mode ))
! {
! $mode = $_CONF['comment_mode'];
! }
! if( empty( $limit ))
! {
! $limit = $_CONF['comment_limit'];
! }
! $template = new Template( $_CONF['path_layout'] . 'comment' );
! $template->set_file( array( 'commentarea' => 'startcomment.thtml' ));
! $template->set_var( 'site_url', $_CONF['site_url'] );
! $template->set_var( 'layout_url', $_CONF['layout_url'] );
! $template->set_var( 'commentbar',
! COM_commentBar( $sid, $title, $type, $order, $mode ));
! if ( $mode == 'nested' or $mode == 'threaded' or $mode == 'flat' )
! {
! // build query
! switch( $mode )
{
! case 'flat':
! $q = "SELECT c.*,u.username,unix_timestamp(date) AS nice_date "
! . "FROM {$_TABLES['comments']} as c, {$_TABLES['users']} as u "
! . "WHERE c.uid = u.uid AND sid = '$sid' AND type = '$type' "
! . "ORDER BY date $order LIMIT $limit";
! break;
! case 'nested':
! case 'threaded':
! default:
! $q = "SELECT c.*,u.username,unix_timestamp(date) AS nice_date "
! . "FROM {$_TABLES['comments']} as c, {$_TABLES['users']} as u "
! . "WHERE c.uid = u.uid AND sid = '$sid' AND pid = 0 AND type = '$type' "
! . "ORDER BY date $order LIMIT $limit";
! break;
}
! $thecomments = '';
! $result = DB_query( $q );
! while ($A = DB_fetchArray( $result ))
{
! $thecomments .= COM_getComment( $A, $mode, $type, $order );
}
! $template->set_var( 'comments', $thecomments );
! $retval = $template->parse( 'output', 'commentarea' );
}
***************
*** 4880,4884 ****
// add a link to "search by author"
if( $_CONF["contributedbyline"] == 1 )
! {
$author = DB_getItem( $_TABLES['users'], 'username', "uid = $uid" );
$rel[] = "<a href=\"{$_CONF['site_url']}/search.php?mode=search&type=stories&author=$uid\">{$LANG24[37]} $author</a>";
--- 4797,4801 ----
// add a link to "search by author"
if( $_CONF["contributedbyline"] == 1 )
! {
$author = DB_getItem( $_TABLES['users'], 'username', "uid = $uid" );
$rel[] = "<a href=\"{$_CONF['site_url']}/search.php?mode=search&type=stories&author=$uid\">{$LANG24[37]} $author</a>";
- Previous message (by thread): [geeklog-cvs] geeklog-1.3/public_html/layout/Classic/comment comment.thtml,NONE,1.1 thread.thtml,NONE,1.1 startcomment.thtml,1.1,1.2
- Next message (by thread): [geeklog-cvs] geeklog-1.3/public_html/layout/Digital_Monochrome/comment comment.thtml,NONE,1.1 thread.thtml,NONE,1.1 startcomment.thtml,1.1,1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the geeklog-cvs
mailing list