[geeklog-cvs] geeklog-1.3/system lib-comment.php,1.5,1.6 lib-plugins.php,1.53,1.54
vinny at iowaoutdoors.org
vinny at iowaoutdoors.org
Thu Jan 27 23:49:12 EST 2005
Update of /var/cvs/geeklog-1.3/system
In directory www:/tmp/cvs-serv27642/system
Modified Files:
lib-comment.php lib-plugins.php
Log Message:
Checkin comment refactoring for plugins.
Index: lib-comment.php
===================================================================
RCS file: /var/cvs/geeklog-1.3/system/lib-comment.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** lib-comment.php 27 Jan 2005 09:22:28 -0000 1.5
--- lib-comment.php 28 Jan 2005 04:49:10 -0000 1.6
***************
*** 179,188 ****
*
*/
! function CMT_getComment( &$comments, $mode, $type, $order, $delete_option = false, $preview = false )
! {
global $_CONF, $_TABLES, $_USER, $LANG01, $query;
$indent = 0; // begin with 0 indent
- $level = array(); // used to track depth
$retval = ''; // initialize return value
--- 179,186 ----
*
*/
! function CMT_getComment( &$comments, $mode, $type, $order, $delete_option = false, $preview = false ) {
global $_CONF, $_TABLES, $_USER, $LANG01, $query;
$indent = 0; // begin with 0 indent
$retval = ''; // initialize return value
***************
*** 201,211 ****
// Make sure we have a default value for comment indentation
! if( !isset( $_CONF['comment_indent'] ))
! {
$_CONF['comment_indent'] = 25;
}
! if( $preview )
! {
$A = $comments;
if( empty( $A['nice_date'] ))
--- 199,207 ----
// Make sure we have a default value for comment indentation
! if( !isset( $_CONF['comment_indent'] )) {
$_CONF['comment_indent'] = 25;
}
! if( $preview ) {
$A = $comments;
if( empty( $A['nice_date'] ))
***************
*** 214,233 ****
}
$mode = 'flat';
! }
! else
! {
$A = DB_fetchArray($comments);
}
! if( empty( $A ) )
! {
return '';
}
! do
! {
// determines indentation for current comment
! if( $mode == 'threaded' || $mode == 'nested' )
! {
$indent = ($A['indent'] - $A['pindent']) * $_CONF['comment_indent'];
}
--- 210,224 ----
}
$mode = 'flat';
! } else {
$A = DB_fetchArray($comments);
}
! if( empty( $A ) ) {
return '';
}
! do {
// determines indentation for current comment
! if( $mode == 'threaded' || $mode == 'nested' ) {
$indent = ($A['indent'] - $A['pindent']) * $_CONF['comment_indent'];
}
***************
*** 238,256 ****
$template->set_var( 'author_id', $A['uid'] );
! if( $A['uid'] > 1 )
! {
! if( empty( $A['fullname'] ))
! {
$template->set_var( 'author_fullname', $A['username'] );
$alttext = $A['username'];
! }
! else
! {
$template->set_var( 'author_fullname', $A['fullname'] );
$alttext = $A['fullname'];
}
! if( !empty( $A['photo'] ))
! {
$template->set_var( 'author_photo', '<img src="'
. $_CONF['site_url']
--- 229,242 ----
$template->set_var( 'author_id', $A['uid'] );
! if( $A['uid'] > 1 ) {
! if( empty( $A['fullname'] )) {
$template->set_var( 'author_fullname', $A['username'] );
$alttext = $A['username'];
! } else {
$template->set_var( 'author_fullname', $A['fullname'] );
$alttext = $A['fullname'];
}
! if( !empty( $A['photo'] )) {
$template->set_var( 'author_photo', '<img src="'
. $_CONF['site_url']
***************
*** 262,268 ****
. '"><img src="' . $_CONF['layout_url']
. '/images/smallcamera.gif" border="0" alt=""></a>' );
! }
! else
! {
$template->set_var( 'author_photo', '' );
$template->set_var( 'camera_icon', '' );
--- 248,252 ----
. '"><img src="' . $_CONF['layout_url']
. '/images/smallcamera.gif" border="0" alt=""></a>' );
! } else {
$template->set_var( 'author_photo', '' );
$template->set_var( 'camera_icon', '' );
***************
*** 273,279 ****
. $A['uid'] . '">' );
$template->set_var( 'end_author_anchortag', '</a>' );
! }
! else
! {
$template->set_var( 'author_fullname', $A['username'] );
$template->set_var( 'author_photo', '' );
--- 257,261 ----
. $A['uid'] . '">' );
$template->set_var( 'end_author_anchortag', '</a>' );
! } else {
$template->set_var( 'author_fullname', $A['username'] );
$template->set_var( 'author_photo', '' );
***************
*** 285,306 ****
// hide reply link from anonymous users if they can't post replies
$hidefromanon = false;
! if( empty( $_USER['username'] ) && (( $_CONF['loginrequired'] == 1 ) || ( $_CONF['commentsloginrequired'] == 1 )))
! {
$hidefromanon = true;
}
// this will hide HTML that should not be viewed in preview mode
! if( $preview || $hidefromanon )
! {
$template->set_var( 'hide_if_preview', 'style="display:none"' );
! }
! else
! {
$template->set_var( 'hide_if_preview', '' );
}
// for threaded mode, add a link to comment parent
! if( $mode == 'threaded' && $A['pid'] != 0 && $indent == 0 )
! {
$result = DB_query( "SELECT title,pid from {$_TABLES['comments']} where cid = '{$A['pid']}'" );
$P = DB_fetchArray( $result );
--- 267,284 ----
// hide reply link from anonymous users if they can't post replies
$hidefromanon = false;
! if( empty( $_USER['username'] ) && (( $_CONF['loginrequired'] == 1 )
! || ( $_CONF['commentsloginrequired'] == 1 ))) {
$hidefromanon = true;
}
// this will hide HTML that should not be viewed in preview mode
! if( $preview || $hidefromanon ) {
$template->set_var( 'hide_if_preview', 'style="display:none"' );
! } else {
$template->set_var( 'hide_if_preview', '' );
}
// for threaded mode, add a link to comment parent
! if( $mode == 'threaded' && $A['pid'] != 0 && $indent == 0 ) {
$result = DB_query( "SELECT title,pid from {$_TABLES['comments']} where cid = '{$A['pid']}'" );
$P = DB_fetchArray( $result );
***************
*** 317,323 ****
}
$template->set_var( 'parent_link', "| <a href=\"$plink\">{$LANG01[44]}</a>");
! }
! else
! {
$template->set_var( 'parent_link', '');
}
--- 295,299 ----
}
$template->set_var( 'parent_link', "| <a href=\"$plink\">{$LANG01[44]}</a>");
! } else {
$template->set_var( 'parent_link', '');
}
***************
*** 328,345 ****
// If deletion is allowed, displays delete link
! if( $delete_option )
! {
$deloption = '| <a href="' . $_CONF['site_url']
. '/comment.php?mode=delete&cid='
. $A['cid'] . '&sid=' . $A['sid'] . '&type='
. $type . '">' . $LANG01[28] . '</a> ';
! if( !empty( $A['ipaddress'] ))
! {
! if( empty( $_CONF['ip_lookup'] ))
! {
$deloption .= '| ' . $A['ipaddress'] . ' ';
! }
! else
! {
$iplookup = str_replace( '*', $A['ipaddress'],
$_CONF['ip_lookup'] );
--- 304,316 ----
// If deletion is allowed, displays delete link
! if( $delete_option ) {
$deloption = '| <a href="' . $_CONF['site_url']
. '/comment.php?mode=delete&cid='
. $A['cid'] . '&sid=' . $A['sid'] . '&type='
. $type . '">' . $LANG01[28] . '</a> ';
! if( !empty( $A['ipaddress'] )) {
! if( empty( $_CONF['ip_lookup'] )) {
$deloption .= '| ' . $A['ipaddress'] . ' ';
! } else {
$iplookup = str_replace( '*', $A['ipaddress'],
$_CONF['ip_lookup'] );
***************
*** 349,355 ****
}
$template->set_var( 'delete_option', $deloption );
! }
! else if( !empty( $_USER['username'] ))
! {
$reportthis = ' | <a href="' . $_CONF['site_url']
. '/comment.php?mode=report&cid=' . $A['cid']
--- 320,324 ----
}
$template->set_var( 'delete_option', $deloption );
! } else if( !empty( $_USER['username'] )) {
$reportthis = ' | <a href="' . $_CONF['site_url']
. '/comment.php?mode=report&cid=' . $A['cid']
***************
*** 357,363 ****
. '">' . $LANG01[109] . '</a> ';
$template->set_var( 'delete_option', $reportthis );
! }
! else
! {
$template->set_var( 'delete_option', '' );
}
--- 326,330 ----
. '">' . $LANG01[109] . '</a> ';
$template->set_var( 'delete_option', $reportthis );
! } else {
$template->set_var( 'delete_option', '' );
}
***************
*** 369,380 ****
// 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'] );
}
// highlight search terms if specified
! if( !empty( $query ))
! {
$A['comment'] = COM_highlightQuery( $A['comment'], $query );
}
--- 336,345 ----
// 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'] );
}
// highlight search terms if specified
! if( !empty( $query )) {
$A['comment'] = COM_highlightQuery( $A['comment'], $query );
}
***************
*** 391,406 ****
// parse the templates
! if( $mode == 'threaded' && $indent > 0 )
! {
$template->set_var( 'pid', $A['pid'] );
$retval .= $template->parse( 'output', 'thread' );
! }
! else
! {
$template->set_var( 'pid', $A['cid'] );
$retval .= $template->parse( 'output', 'comment' );
}
! }
! while( $A = DB_fetchArray( $comments ));
return $retval;
--- 356,367 ----
// parse the templates
! if( $mode == 'threaded' && $indent > 0 ) {
$template->set_var( 'pid', $A['pid'] );
$retval .= $template->parse( 'output', 'thread' );
! } else {
$template->set_var( 'pid', $A['cid'] );
$retval .= $template->parse( 'output', 'comment' );
}
! } while( $A = DB_fetchArray( $comments ));
return $retval;
***************
*** 430,443 ****
global $_CONF, $_TABLES, $_USER, $LANG01;
! if( !empty( $_USER['uid'] ) )
! {
$result = DB_query( "SELECT commentorder,commentmode,commentlimit FROM {$_TABLES['usercomment']} WHERE uid = '{$_USER['uid']}'" );
$U = DB_fetchArray( $result );
! if( empty( $order ) )
! {
$order = $U['commentorder'];
}
! if( empty( $mode ) )
! {
$mode = $U['commentmode'];
}
--- 391,401 ----
global $_CONF, $_TABLES, $_USER, $LANG01;
! if( !empty( $_USER['uid'] ) ) {
$result = DB_query( "SELECT commentorder,commentmode,commentlimit FROM {$_TABLES['usercomment']} WHERE uid = '{$_USER['uid']}'" );
$U = DB_fetchArray( $result );
! if( empty( $order ) ) {
$order = $U['commentorder'];
}
! if( empty( $mode ) ) {
$mode = $U['commentmode'];
}
***************
*** 445,465 ****
}
! if( empty( $order ))
! {
$order = 'ASC';
}
! if( empty( $mode ))
! {
$mode = $_CONF['comment_mode'];
}
! if( empty( $limit ))
! {
$limit = $_CONF['comment_limit'];
}
! if( !is_numeric($page) || $page < 1 )
! {
$page = 1;
}
--- 403,419 ----
}
! if( empty( $order )) {
$order = 'ASC';
}
! if( empty( $mode )) {
$mode = $_CONF['comment_mode'];
}
! if( empty( $limit )) {
$limit = $_CONF['comment_limit'];
}
! if( !is_numeric($page) || $page < 1 ) {
$page = 1;
}
***************
*** 474,485 ****
CMT_commentBar( $sid, $title, $type, $order, $mode));
! if( $mode == 'nested' or $mode == 'threaded' or $mode == 'flat' )
! {
// build query
! switch( $mode )
! {
case 'flat':
! if( $cid )
! {
$count = 1;
--- 428,436 ----
CMT_commentBar( $sid, $title, $type, $order, $mode));
! if( $mode == 'nested' or $mode == 'threaded' or $mode == 'flat' ) {
// build query
! switch( $mode ) {
case 'flat':
! if( $cid ) {
$count = 1;
***************
*** 488,494 ****
. "FROM {$_TABLES['comments']} as c, {$_TABLES['users']} as u "
. "WHERE c.uid = u.uid AND c.cid = $pid";
! }
! else
! {
$count = DB_count( $_TABLES['comments'], 'sid', $sid );
--- 439,443 ----
. "FROM {$_TABLES['comments']} as c, {$_TABLES['users']} as u "
. "WHERE c.uid = u.uid AND c.cid = $pid";
! } else {
$count = DB_count( $_TABLES['comments'], 'sid', $sid );
***************
*** 504,513 ****
case 'threaded':
default:
! if( $order == 'DESC' )
! {
$cOrder = 'c.rht DESC';
! }
! else
! {
$cOrder = 'c.lft ASC';
}
--- 453,459 ----
case 'threaded':
default:
! if( $order == 'DESC' ) {
$cOrder = 'c.rht DESC';
! } else {
$cOrder = 'c.lft ASC';
}
***************
*** 515,520 ****
// We can simplify the query, and hence increase performance
// when pid = 0 (when fetching all the comments for a given sid)
! if( $cid )
! {
// count the total number of applicable comments
$q2 = "SELECT COUNT(*) "
--- 461,465 ----
// We can simplify the query, and hence increase performance
// when pid = 0 (when fetching all the comments for a given sid)
! if( $cid ) {
// count the total number of applicable comments
$q2 = "SELECT COUNT(*) "
***************
*** 532,540 ****
. "AND c2.cid = $pid AND c.uid = u.uid "
. "ORDER BY $cOrder LIMIT $start, $limit";
! }
! else
! {
! if( $pid == 0 )
! {
// count the total number of applicable comments
$count = DB_count( $_TABLES['comments'], 'sid', $sid );
--- 477,482 ----
. "AND c2.cid = $pid AND c.uid = u.uid "
. "ORDER BY $cOrder LIMIT $start, $limit";
! } else {
! if( $pid == 0 ) {
// count the total number of applicable comments
$count = DB_count( $_TABLES['comments'], 'sid', $sid );
***************
*** 545,551 ****
. "WHERE c.sid = '$sid' AND c.uid = u.uid "
. "ORDER BY $cOrder LIMIT $start, $limit";
! }
! else
! {
// count the total number of applicable comments
$q2 = "SELECT COUNT(*) "
--- 487,491 ----
. "WHERE c.sid = '$sid' AND c.uid = u.uid "
. "ORDER BY $cOrder LIMIT $start, $limit";
! } else {
// count the total number of applicable comments
$q2 = "SELECT COUNT(*) "
***************
*** 770,774 ****
* Save a comment
*
! * @author Vincent Furia <vinny01 AT users DOT sourceforge DOT net>
* @param string $title Title of comment
* @param string $comment Text of comment
--- 710,714 ----
* Save a comment
*
! * @author Vincent Furia <vinny01 AT users DOT sourceforge DOT net>
* @param string $title Title of comment
* @param string $comment Text of comment
***************
*** 960,968 ****
* for the specified $type and $sid.
*
! * @author Vincent Furia <vinny01 AT users DOT sourceforge DOT net>
* @param string $type article, poll, or plugin identifier
* @param string $sid id of object comment belongs to
* @param int $cid Comment ID
! * @return string null indicates success, string identifies problem
*/
function CMT_deleteComment ($cid, $sid, $type) {
--- 900,908 ----
* for the specified $type and $sid.
*
! * @author Vincent Furia <vinny01 AT users DOT sourceforge DOT net>
* @param string $type article, poll, or plugin identifier
* @param string $sid id of object comment belongs to
* @param int $cid Comment ID
! * @return string 0 indicates success, >0 identifies problem
*/
function CMT_deleteComment ($cid, $sid, $type) {
Index: lib-plugins.php
===================================================================
RCS file: /var/cvs/geeklog-1.3/system/lib-plugins.php,v
retrieving revision 1.53
retrieving revision 1.54
diff -C2 -d -r1.53 -r1.54
*** lib-plugins.php 16 Jan 2005 19:14:29 -0000 1.53
--- lib-plugins.php 28 Jan 2005 04:49:10 -0000 1.54
***************
*** 112,115 ****
--- 112,121 ----
return $function($args[1], $args[2], $args[3], $args[4], $args[5]);
break;
+ case 6:
+ return $function($args[1], $args[2], $args[3], $args[4], $args[5], $args[6]);
+ break;
+ case 7:
+ return $function($args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7]);
+ break;
default:
return $function($args);
***************
*** 219,247 ****
/**
! * Returns if a specific plugin supports user comments
! *
! * @param string $type Plugin to check comment support for
! * @return boolean True if plugin uses comments otherwise false
! *
! */
! function PLG_supportsComments($type)
! {
! return PLG_callFunctionForOnePlugin('plugin_commentsupport_' . $type);
}
/**
! * Plugin should perform an operation on one of its comments.
! *
! * @param string $type Plugin to have handle the comment
! * @param string $id Comment ID
! * @param string $operation "save" or "delete"
! * @return string COM_refresh() string to redirect to the proper URL
! */
! function PLG_handlePluginComment ($type, $id, $operation='')
! {
$args[1] = $id;
! $args[2] = $operation;
! return PLG_callFunctionForOnePlugin('plugin_handlecomment_' . $type, $args);
}
--- 225,289 ----
/**
! * Plugin should delete a comment
! *
! * @author Vincnet Furia <vinny01 AT users DOT sourceforge DOT net>
! * @param string $type Plugin to delete comment
! * @param int $cid Comment to be deleted
! * @param string $id Item id to which $cid belongs
! * @return mixed false for failure, HTML string (redirect?) for success
! */
! function PLG_commentDelete($type, $cid, $id) {
! $args[1] = $cid;
! $args[2] = $id;
!
! return PLG_callFunctionForOnePlugin('plugin_deletecomment_' . $type, $args);
}
/**
! * Plugin should save a comment
! *
! * @author Vincnet Furia <vinny01 AT users DOT sourceforge DOT net>
! * @param string $type Plugin to delete comment
! * @param string $title comment title
! * @param string $comment comment text
! * @param string $id Item id to which $cid belongs
! * @param int $pid comment parent
! * @param string $postmode 'html' or 'text'
! * @return mixed false for failure, HTML string (redirect?) for success
! */
! function PLG_commentSave($type, $title, $comment, $id, $pid, $postmode) {
! $args[1] = $title;
! $args[2] = $comment;
! $args[3] = $id;
! $args[4] = $pid;
! $args[5] = $postmode;
!
! return PLG_callFunctionForOnePlugin('plugin_savecomment_' . $type, $args);
! }
!
! /**
! * Plugin should display [a] comment[s]
! *
! * @author Vincnet Furia <vinny01 AT users DOT sourceforge DOT net>
! * @param string $type Plugin to display comment
! * @param string $id Unique idenifier for item comment belongs to
! * @param int $cid Comment id to display (possibly including sub-comments)
! * @param string $title Page/comment title
! * @param string $order 'ASC' or 'DSC' or blank
! * @param string $format 'threaded', 'nested', or 'flat'
! * @param int $page Page number of comments to display
! * @param boolean $view True to view comment (by cid), false to display (by $pid)
! * @return mixed results of calling the plugin_displaycomment_ function
! */
! function PLG_displayComment($type, $id, $cid, $title, $order, $format, $page, $view) {
$args[1] = $id;
! $args[2] = $cid;
! $args[3] = $title;
! $args[4] = $order;
! $args[5] = $format;
! $args[6] = $page;
! $args[7] = $view;
! return PLG_callFunctionForOnePlugin('plugin_displaycomment_' . $type, $args);
}
***************
*** 280,306 ****
}
- /**
- * User has requested to create a comment for the plugin
- * Redirects user to comment form if initial comment for plugin record or returns
- * formated HTML including the Site footer and the comments
- *
- * @param string $type Plugin to have handle the comment
- * @param int $id GL Comment table primary key.
- * @param string $mode Has user selected a new comment preview mode (Flat, Nested, Threaded, None)
- * @param string $order Has the user selected a different comment first (Newest or Oldest comment first)
- * @param string $reply Has the user used the reply button on the Comment Bar
- * @return string Formated HTML containing site footer and the comments with the comment command bar
- * or redirect user to create top level comment
- */
- function PLG_callCommentForm($type,$id,$mode="",$order="",$reply="")
- {
- $args[1] = $id;
- $args[2] = $mode;
- $args[3] = $order;
- $args[4] = $reply;
-
- return PLG_callFunctionForOnePlugin('plugin_commentform_' . $type, $args);
- }
-
/**
--- 322,325 ----
More information about the geeklog-cvs
mailing list