Version 3.2.3

This commit is contained in:
Neo committed 2025-12-19 00:34:03 -08:00
1 parent ae5c01cc78
commit 78706903a2
2641 files changed
+228363 -201264

No files matched your search

@@ -4,10 +4,10 @@
*
* @author Matt Mecham
* @copyright (c) 2001 - 2010 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @license This is NULLED!
* @package Core
* @link http://www.invisionpower.com
* @version $Rev: 6651 $
* @link http://hatynka.in
* @version $Rev: 9602 $
*
*/
@@ -30,17 +30,17 @@ class classes_comments_bootstrap
{
list( $app, $key ) = explode( '-', $app );
}
$_file = IPSLib::getAppDir( $app ) . '/extensions/comments/' . $key . '.php';
$_class = 'comments_' . $app . '_' . $key;
if ( file_exists( $_file ) )
if ( is_file( $_file ) )
{
require_once( $_file );
if ( class_exists( $_class ) )
$classToLoad = IPSLib::loadLibrary( $_file, $_class, $app );
if ( class_exists( $classToLoad ) )
{
self::$_app = new $_class();
self::$_app = new $classToLoad();
self::$_app->init();
}
else
@@ -55,7 +55,7 @@ class classes_comments_bootstrap
/* Load up language file */
$registry = ipsRegistry::instance();
$registry->getClass('class_localization')->loadLanguageFile( array( 'public_comments' ), 'core' );
$registry->getClass('class_localization')->loadLanguageFile( array( 'public_comments', 'public_editors' ), 'core' );
return self::$_app;
}
@@ -74,7 +74,9 @@ abstract class classes_comments_renderer
protected $request;
protected $lang;
protected $member;
protected $memberData;
protected $cache;
protected $caches;
/**#@-*/
protected $_cache = array();
@@ -91,17 +93,35 @@ abstract class classes_comments_renderer
* @param array
*/
protected $_settings;
/**
* Constructor
* CONSTRUCTOR
*
* @param ipsRegistry $registry
* @param string App key to use will use current app if none specified
* @return void
* @return @e void
*/
public function __construct()
{
/* Make registry objects */
$this->registry = ipsRegistry::instance();
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->lang = $this->registry->getClass('class_localization');
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
}
/**
* Init method
*
* @return @e void
*/
public function init()
{
$this->lang->loadLanguageFile( array( 'public_topic' ), 'forums' );
/* Init some data */
$this->_settings = $this->settings();
$this->qpids = IPSCookie::get( 'comment_pids' );
@@ -110,6 +130,24 @@ abstract class classes_comments_renderer
IPSCookie::set('commentmodpids', '', 0);
}
/**
* Get report center library
*
* @return @e object
*/
public function getReportLibrary()
{
static $reports = null;
if( !$reports )
{
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir('core') . '/sources/classes/reportLibrary.php', 'reportLibrary', 'core' );
$reports = new $classToLoad( $this->registry );
}
return $reports;
}
/**
* Fetch setting
*
@@ -151,6 +189,7 @@ abstract class classes_comments_renderer
$_remap = $this->remapKeys();
$parent = $this->remapFromLocal( $parent, 'parent' );
$preReply = '';
$data = array( 'counts' => array( 'commentTotal' => 0,
'thisPageCount' => 0,
'perPage' => $filters['limit'],
@@ -158,11 +197,13 @@ abstract class classes_comments_renderer
/* Fetch raw data */
$comments = $this->fetch( $parent, $filters );
list( $app, $_where ) = explode( '-', $this->whoAmI() );
if ( $comments === false )
{
return false;
}
/* Can comment */
$parent['_canComment'] = ( $this->can( 'add', array( 'comment_parent_id' => $parent['parent_id'] ) ) === true ) ? true : false;
@@ -185,6 +226,7 @@ abstract class classes_comments_renderer
'itemsPerPage' => $filters['limit'],
'currentStartValue' => $filters['offset'],
'baseUrl' => sprintf( $this->fetchSetting('urls-showParent', $parent), $parent['parent_id'] ),
'anchor' => 'commentsStart',
'base' => 'public',
'seoTitle' => $parent['parent_seo_title'],
'seoTemplate' => $this->seoTemplate() ) );
@@ -192,20 +234,36 @@ abstract class classes_comments_renderer
}
$data['settings'] = $this->settings();
$data['canModerate'] = ( $parent['_canModerate'] ) ? true : false;
$data['fromApp'] = $this->whoAmI();
$data['_app'] = preg_replace( '#^(.+?)(?:-.*|$)#', '\\1', $this->whoAmI() );
$data['settings'] = $this->settings();
$data['canModerate'] = ( $parent['_canModerate'] ) ? true : false;
$data['fromApp'] = $this->whoAmI();
$data['thisApp'] = $app;
$data['repType'] = $_remap['comment_id'];
$data['enableRep'] = $this->reputationEnabled();
$data['autoSaveKey'] = 'comment-' . $this->table() . '-' . $parent['parent_id'];
$data['captcha'] = $this->getCaptcha();
/* Got a reply? */
if ( isset( $this->request['_rcid'] ) AND $this->request['_rcid'] )
if ( !empty( $this->request['_rcid'] ) )
{
$preReply = $this->fetchReply( $parent['parent_id'], $this->request['_rcid'], $this->memberData );
}
return $this->registry->output->getTemplate( $this->skin() )->commentsList( $comments, $data, $pages, $parent, $preReply );
}
/**
* Returns recaptcha data if we are a guest
*/
public function getCaptcha()
{
if( !$this->memberData['member_id'] AND $this->settings['guest_captcha'] )
{
return $this->registry->getClass('class_captcha')->getTemplate();
}
}
/**
* Fetch a total count of comments we can see
*
@@ -257,6 +315,8 @@ abstract class classes_comments_renderer
$parent = $this->remapFromLocal( $parent, 'parent' );
$_remap = $this->remapKeys();
list( $app, $_where ) = explode( '-', $this->whoAmI() );
/* Fetch raw data */
$comments = $this->fetch( $parent, $filters );
$comment = array_pop( $comments );
@@ -267,11 +327,13 @@ abstract class classes_comments_renderer
}
/* Can moderate? */
$parent['_canModerate'] = $this->can( 'moderate', array( 'comment_parent_id' => $parent['parent_id'] ) );
$parent['_canModerate'] = $this->can( 'moderate', array( 'comment_parent_id' => $parent['parent_id'] ) ) === true ? true: false;
$data['settings'] = $this->settings();
$data['fromApp'] = $this->whoAmI();
$data['_app'] = preg_replace( '#^(.+?)(?:-.*|$)#', '\\1', $this->whoAmI() );
$data['settings'] = $this->settings();
$data['fromApp'] = $this->whoAmI();
$data['thisApp'] = $app;
$data['repType'] = $_remap['comment_id'];
$data['enableRep'] = $this->reputationEnabled();
return $this->registry->output->getTemplate( $this->skin() )->comment( $comment, $parent, $data );
}
@@ -285,7 +347,7 @@ abstract class classes_comments_renderer
{
$_remap = $this->remapKeys();
if ( ! array_key_exists( $commentId, $this->_cache ) )
if ( ! isset( $this->_cache[ $commentId ] ) )
{
$comment = $this->DB->buildAndFetch( array( 'select' => '*',
'from' => $this->table(),
@@ -314,41 +376,41 @@ abstract class classes_comments_renderer
}
/* Set filters */
$filters = $this->_setFilters( $filters );
$parent = $this->remapFromLocal( $parent, 'parent' );
$comments = array();
$q = array();
$_remap = $this->remapKeys();
$filters = $this->_setFilters( $filters );
$parent = $this->remapFromLocal( $parent, 'parent' );
$comments = array();
$q = array();
$_remap = $this->remapKeys();
list( $app, $_where ) = explode( '-', $this->whoAmI() );
/* unpack cache */
$this->_unpackRepCache();
/* Joins */
$_post_joins = array( array( 'type' => 'left',
'select' => 'm.*',
$_post_joins = array( array( 'select' => 'm.*',
'where' => 'm.member_id=c.' . $_remap['comment_author_id'],
'from' => array( 'members' => 'm' ) ),
array( 'type' => 'left',
'select' => 'pc.*',
'from' => array( 'members' => 'm' ),
'type' => 'left', ),
array( 'select' => 'pc.*',
'where' => 'pc.member_id=m.member_id',
'from' => array( 'pfields_content' => 'pc' ) ),
array( 'type' => 'left',
'select' => 'pp.*',
'from' => array( 'pfields_content' => 'pc' ),
'type' => 'left', ),
array( 'select' => 'pp.*',
'where' => 'pp.pp_member_id=m.member_id',
'from' => array( 'profile_portal' => 'pp' ) ) );
'from' => array( 'profile_portal' => 'pp' ),
'type' => 'left', ),
);
/* Reputation system enabled? */
if ( $this->settings['reputation_enabled'] )
{
/* Add the join to figure out if the user has already rated the post */
$_post_joins[] = $this->registry->repCache->getUserHasRatedJoin( $_remap['comment_id'], 'c.' . $_remap['comment_id'], $this->whoAmI() );
$_post_joins[] = $this->registry->repCache->getUserHasRatedJoin( $_remap['comment_id'], 'c.' . $_remap['comment_id'], $app );
/* Add the join to figure out the total ratings for each post */
if( $this->settings['reputation_show_content'] )
{
$_post_joins[] = $this->registry->repCache->getTotalRatingJoin( $_remap['comment_id'], 'c.' . $_remap['comment_id'], $this->whoAmI() );
$_post_joins[] = $this->registry->repCache->getTotalRatingJoin( $_remap['comment_id'], 'c.' . $_remap['comment_id'], $app );
}
}
@@ -356,9 +418,9 @@ abstract class classes_comments_renderer
$q[] = "c." . $_remap['comment_parent_id'] . "=" . $parent['parent_id'];
/* Can moderate? */
if ( ! $this->can( 'moderate', array( 'comment_parent_id' => $parent['parent_id'] ) ) )
if ( $this->can( 'moderate', array( 'comment_parent_id' => $parent['parent_id'] ) ) !== true )
{
$q[] = $_remap['comment_approved'] . '=1';
$q[] = 'c.' . $_remap['comment_approved'] . '=1';
}
/* Fetching a single comment? */
@@ -366,37 +428,39 @@ abstract class classes_comments_renderer
{
if ( is_numeric( $filters['comment_id'] ) )
{
$q[] = $_remap['comment_id'] . '=' . intval( $filters['comment_id'] );
$q[] = 'c.' . $_remap['comment_id'] . '=' . intval( $filters['comment_id'] );
}
else if ( is_array( $filters['comment_id'] ) )
{
$q[] = $_remap['comment_id'] . ' IN(' . implode( ",", IPSLib::cleanIntArray( $filters['comment_id'] ) ) . ')';
$q[] = 'c.' . $_remap['comment_id'] . ' IN(' . implode( ",", IPSLib::cleanIntArray( $filters['comment_id'] ) ) . ')';
}
}
/* Set up parser */
IPSText::getTextClass( 'bbcode' )->parse_html = 0;
IPSText::getTextClass( 'bbcode' )->parse_wordwrap = $this->settings['post_wordwrap'];
IPSText::getTextClass( 'bbcode' )->parse_nl2br = 1;
IPSText::getTextClass( 'bbcode' )->parse_bbcode = 1;
IPSText::getTextClass( 'bbcode' )->parsing_section = $this->whoAmI() . '_comment';
IPSText::getTextClass('bbcode')->parse_html = 0;
IPSText::getTextClass('bbcode')->parse_nl2br = 1;
IPSText::getTextClass('bbcode')->parse_bbcode = 1;
IPSText::getTextClass('bbcode')->parsing_section = $this->bbcodeSection();
/* Fetch the data */
$this->DB->build( array( 'select' => 'c.*',
'from' => array( $this->table() => 'c' ),
'where' => implode( ' AND ', $q ),
'order' => $_remap[ $filters['sortKey'] ] . ' ' . $_remap[ $filters['sortOrder'] ],
'order' => $_remap[ $filters['sortKey'] ] . ' ' . $filters['sortOrder'],
'limit' => array( $filters['offset'], $filters['limit'] ),
'add_join' => $_post_joins ) );
$oq = $this->DB->execute();
/* Go get 'em bawss */
while( $row = $this->DB->fetch( $oq ) )
{
/* Reset member ID */
$row['member_id'] = $row[ $_remap['comment_author_id'] ];
/* Set up parser */
IPSText::getTextClass( 'bbcode' )->parsing_mgroup = $row['member_group_id'];
IPSText::getTextClass( 'bbcode' )->parsing_mgroup_others = $row['mgroup_others'];
IPSText::getTextClass('bbcode')->parsing_mgroup = $row['member_group_id'];
IPSText::getTextClass('bbcode')->parsing_mgroup_others = $row['mgroup_others'];
/* Remap */
$row = $this->remapFromLocal( $row );
@@ -444,10 +508,13 @@ abstract class classes_comments_renderer
}
/* Edit button */
$row['_canEdit'] = $this->can('edit', $row);
$row['_canEdit'] = ( $this->can('edit', $row) === true ) ? 1 : 0;
/* Edit button */
$row['_canDelete'] = $this->can('delete', $row);
/* Delete button */
$row['_canDelete'] = ( $this->can('delete', $row) === true ) ? 1 : 0;
/* Reply button */
$row['_canReply'] = ( $this->can('add', $row) === true ) ? 1 : 0;
/* Report link */
if ( $this->fetchSetting('urls-report', $parent) )
@@ -467,13 +534,20 @@ abstract class classes_comments_renderer
}
/* Ensure parity */
$row['member_id'] = $row['comment_author_id'];
$row['member_id'] = $row['comment_author_id'];
$row['members_display_name'] = $row['members_display_name'] ? $row['members_display_name'] : $this->lang->words['global_guestname'];
/* Reputation */
if ( $this->settings['reputation_enabled'] )
{
$row['like'] = $this->registry->repCache->getLikeFormatted( array( 'app' => $app, 'type' => $_remap['comment_id'], 'id' => $row['comment_id'], 'rep_like_cache' => $row['rep_like_cache'] ) );
}
/* Done */
$comments[ $row['comment_id'] ] = array( 'author' => IPSMember::buildDisplayData( $row ), 'comment' => $row );
}
return ( is_array( $comments ) ) ? $comments : array();
return is_array($comments) ? $comments : array();
}
/**
@@ -572,6 +646,16 @@ abstract class classes_comments_renderer
/* Load member */
$memberData = IPSMember::load( ( ( $memberId === null ) ? $this->memberData['member_id'] : $memberId ), 'all' );
if( !$memberData['member_id'] )
{
if( !$this->request['comment_name'] )
{
throw new Exception( 'NO_NAME' );
}
$memberData['members_display_name'] = $this->request['comment_name'];
}
/* Permission test */
$can = $this->can('add', array( 'comment_parent_id' => $parentId ) );
@@ -581,12 +665,16 @@ abstract class classes_comments_renderer
}
/* Format comment */
IPSText::getTextClass( 'bbcode' )->parsing_section = $this->whoAmI() . '_comment';
$comment = IPSText::getTextClass( 'editor' )->processRawPost( $post );
IPSText::getTextClass( 'bbcode' )->parsing_section = $this->bbcodeSection();
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/editor/composite.php', 'classes_editor_composite' );
$editor = new $classToLoad();
$comment = $editor->process( $post );
$comment = IPSText::getTextClass( 'bbcode' )->preDbParse( $comment );
/* Build insert data */
$array = array( 'comment_author_id' => $memberData['member_id'],
$array = array( 'comment_author_id' => intval( $memberData['member_id'] ),
'comment_author_name' => $memberData['members_display_name'],
'comment_ip_address' => $this->member->ip_address,
'comment_date' => time(),
@@ -605,12 +693,18 @@ abstract class classes_comments_renderer
$insert['comment_id'] = $this->DB->getInsertId();
/* Post save */
$this->postSave( 'add', $insert );
$this->postSave( 'add', $insert, $insert['comment_id'], $parentId );
/* remove saved content */
if ( $this->memberData['member_id'] )
{
$editor->removeAutoSavedContent( array( 'member_id' => $this->memberData['member_id'], 'autoSaveKey' => 'comment-' . $this->table() . '-' . $parentId ) );
}
/* Send notifications */
$this->sendNotifications( $this->remapFromLocal( $insert ), $comment );
return $insert['comment_id'];
return $insert;
}
/**
@@ -632,22 +726,29 @@ abstract class classes_comments_renderer
/* Fetch meta data */
$parent = $this->remapFromLocal( $this->fetchParent( $array['comment_parent_id'] ), 'parent' );
$_url = $this->fetchSetting( 'urls-showParent');
$_url = $this->fetchSetting( 'urls-showParent', $parent );
$url = $this->registry->output->buildSEOUrl( sprintf( $_url, $parent['parent_id'] ), 'public', $parent['parent_seo_title'], $this->seoTemplate() );
/* Fetch like class */
require_once( IPS_ROOT_PATH . 'sources/classes/like/composite.php' );
$_like = classes_like::bootstrap( $_app, $_area );
$_like->sendNotifications( $parent['parent_id'], array( 'immediate', 'offline' ), array( 'notification_key' => 'new_comment',
'notification_url' => $url,
'email_template' => 'comment_notifications',
'email_subject' => sprintf( $this->lang->words['comment_notice_subject'], $url, $parent['parent_title'] ),
'build_message_array' => array( 'NAME' => '-member:members_display_name-',
'AUTHOR' => $this->memberData['members_display_name'],
'TITLE' => $parent['parent_title'],
'URL' => $url,
'COMMENT' => $comment ) ) );
try
{
require_once( IPS_ROOT_PATH . 'sources/classes/like/composite.php' );/*noLibHook*/
$_like = classes_like::bootstrap( $_app, $_area );
$_like->sendNotifications( $parent['parent_id'], array( 'immediate', 'offline' ), array( 'notification_key' => 'new_comment',
'notification_url' => $url,
'email_template' => 'comment_notifications',
'email_subject' => sprintf( $this->lang->words['comment_notice_subject'], $url, $parent['parent_title'] ),
'build_message_array' => array( 'NAME' => '-member:members_display_name-',
'AUTHOR' => $this->memberData['members_display_name'],
'TITLE' => $parent['parent_title'],
'URL' => $url,
'COMMENT' => $comment ) ) );
}
catch( Exception $e )
{
/* No like class for this comment class */
}
}
}
@@ -694,16 +795,19 @@ abstract class classes_comments_renderer
IPSText::getTextClass('bbcode')->parse_nl2br = 1;
IPSText::getTextClass('bbcode')->parse_smilies = 1;
IPSText::getTextClass('bbcode')->parse_bbcode = 1;
IPSText::getTextClass('bbcode')->parsing_section = $this->whoAmI . '_comment';
IPSText::getTextClass('bbcode')->parsing_section = $this->bbcodeSection();
$comment = IPSText::getTextClass( 'editor' )->processRawPost( $post );
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/editor/composite.php', 'classes_editor_composite' );
$editor = new $classToLoad();
$comment = $editor->process( $post );
$comment = IPSText::getTextClass( 'bbcode' )->preDbParse( $comment );
/* Update array */
$array = array( 'comment_edit_date' => time(),
'comment_text' => $comment );
/* Pre save */
$update = $this->preSave( 'edit', $array );
$update = $this->preSave( 'edit', $array, $commentId, $parentId );
/* Insert and fetch DB */
$save = $this->remapToLocal( $update );
@@ -712,9 +816,23 @@ abstract class classes_comments_renderer
$this->DB->update( $this->table(), $save, $_remap['comment_id'] . '=' . intval( $commentId ) );
/* Post save */
$this->postSave( 'edit', $update );
$this->postSave( 'edit', $update, $commentId, $parentId );
/* remove saved content */
if ( $this->memberData['member_id'] )
{
$editor->removeAutoSavedContent( array( 'member_id' => $this->memberData['member_id'], 'autoSaveKey' => 'comment-' . $this->table() . '-c' . $commentId ) );
}
/* Format and return */
IPSText::getTextClass('bbcode')->parse_html = 0;
IPSText::getTextClass('bbcode')->parse_nl2br = 1;
IPSText::getTextClass('bbcode')->parse_smilies = 1;
IPSText::getTextClass('bbcode')->parse_bbcode = 1;
IPSText::getTextClass('bbcode')->parsing_section = $this->bbcodeSection();
IPSText::getTextClass('bbcode')->parsing_mgroup = $this->memberData['member_group_id'];
IPSText::getTextClass('bbcode')->parsing_mgroup_others = $this->memberData['mgroup_others'];
return IPSText::getTextClass('bbcode')->preDisplayParse( $comment );
}
@@ -925,7 +1043,7 @@ abstract class classes_comments_renderer
}
/* Check */
if ( ! $memberData['member_id'] OR ! $parentId OR ! $commentId )
if ( ! $parentId OR ! $commentId )
{
throw new Exception('MISSING_DATA');
}
@@ -948,28 +1066,25 @@ abstract class classes_comments_renderer
throw new Exception( $can );
}
/* Process post ready for use */
if ( IPSText::getTextClass('editor')->method == 'rte' )
{
IPSText::getTextClass('bbcode')->parse_wordwrap = 0;
IPSText::getTextClass('bbcode')->parse_html = 0;
IPSText::getTextClass( 'bbcode' )->parse_html = 0;
IPSText::getTextClass( 'bbcode' )->parse_nl2br = 1;
IPSText::getTextClass( 'bbcode' )->parse_bbcode = 1;
IPSText::getTextClass( 'bbcode' )->parse_smilies = 1;
IPSText::getTextClass( 'bbcode' )->parsing_section = $this->bbcodeSection();
$comment['comment']['comment_text'] = IPSText::getTextClass('bbcode')->convertForRTE( $comment['comment']['_db_comment'] );
}
else
$comment['comment']['comment_text'] = IPSText::getTextClass('bbcode')->preEditParse( $comment['comment']['_db_comment'] );
if ( $this->settings['strip_quotes'] )
{
IPSText::getTextClass('bbcode')->parse_html = 0;
IPSText::getTextClass('bbcode')->parse_nl2br = 1;
IPSText::getTextClass('bbcode')->parse_smilies = 1;
IPSText::getTextClass('bbcode')->parse_bbcode = 1;
IPSText::getTextClass('bbcode')->parsing_section = 'gallery_comment';
$comment['comment']['comment_text'] = IPSText::getTextClass('bbcode')->preEditParse( $comment['comment']['_db_comment'] );
$comment['comment']['comment_text'] = IPSText::getTextClass( 'bbcode' )->stripQuotes( $comment['comment']['comment_text'] );
}
$reply = "[quote name='" . IPSText::getTextClass( 'bbcode' )->makeQuoteSafe( $comment['author']['members_display_name'] ) . "' timestamp='" . $comment['comment']['comment_date'] . "']<br />{$comment['comment']['comment_text']}<br />[/quote]<br /><br /><br />";
$reply = "[quote name='" . IPSText::getTextClass('bbcode')->makeQuoteSafe( $comment['author']['members_display_name'] ) . "' timestamp='" . $comment['comment']['comment_date'] . "']<br />{$comment['comment']['comment_text']}<br />[/quote]<br /><br />";
if ( IPSText::getTextClass('editor')->method != 'rte' )
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/editor/composite.php', 'classes_editor_composite' );
$editor = new $classToLoad();
if ( !$editor->getRteEnabled() )
{
$reply = IPSText::br2nl( $reply );
}
@@ -1023,43 +1138,29 @@ abstract class classes_comments_renderer
throw new Exception( $can );
}
/* Process post ready for use */
if ( IPSText::getTextClass('editor')->method == 'rte' )
{
IPSText::getTextClass('bbcode')->parse_wordwrap = 0;
IPSText::getTextClass('bbcode')->parse_html = 0;
IPSText::getTextClass('bbcode')->parse_html = 0;
IPSText::getTextClass('bbcode')->parse_nl2br = 1;
IPSText::getTextClass('bbcode')->parse_smilies = 1;
IPSText::getTextClass('bbcode')->parse_bbcode = 1;
IPSText::getTextClass('bbcode')->parsing_section = $this->bbcodeSection();
$comment['comment']['comment_text'] = IPSText::getTextClass('bbcode')->convertForRTE( $comment['comment']['_db_comment'] );
}
else
{
IPSText::getTextClass('bbcode')->parse_html = 0;
IPSText::getTextClass('bbcode')->parse_nl2br = 1;
IPSText::getTextClass('bbcode')->parse_smilies = 1;
IPSText::getTextClass('bbcode')->parse_bbcode = 1;
IPSText::getTextClass('bbcode')->parsing_section = 'gallery_comment';
$comment['comment']['comment_text'] = IPSText::getTextClass('bbcode')->preEditParse( $comment['comment']['_db_comment'] );
}
/* Load langs */
$this->registry->getClass( 'class_localization')->loadLanguageFile( array( 'public_editors' ), 'core' );
/* Ayjacks? */
if ( $type == 'ajax' )
{
/* Throw, fetch and wag tail */
return $this->registry->getClass('output')->getTemplate('editors')->ajaxEditBox( $comment['comment']['comment_text'], $commentId, array(), array( 'showEditOptions' => false, 'checkBoxes' => false, 'skipFullButton' => true ) );
return $this->registry->getClass('output')->getTemplate('editors')->ajaxEditBox( $comment['comment']['_db_comment'], $commentId, array(), array( 'showEditOptions' => false, 'checkBoxes' => false, 'skipFullButton' => true, 'autoSaveKey' => 'comment-' . $this->table() . '-c' . $commentId ) );
}
else
{
/* Need a bit more dudes */
$editor = IPSText::getTextClass('editor')->showEditor( $comment['comment']['comment_text'], 'Post' );
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/editor/composite.php', 'classes_editor_composite' );
$editor = new $classToLoad();
$_editor = $editor->show( 'Post', array( 'type' => 'mini', 'autoSaveKey' => 'comment-' . $this->table() . '-c' . $commentId ), $comment['comment']['_db_comment'] );
$settings = array( 'fromApp' => $this->whoAmI(),
'_app' => preg_replace( '#^(.+?)(?:-.*|$)#', '\\1', $this->whoAmI() ) );
'thisApp' => preg_replace( '#^(.+?)(?:-.*|$)#', '\\1', $this->whoAmI() ) );
return $this->registry->getClass('output')->getTemplate( $this->skin() )->form( $comment, $parent, $editor, $settings, array(), 'saveEdit' );
return $this->registry->getClass('output')->getTemplate( $this->skin() )->form( $comment, $parent, $_editor, $settings, array(), 'saveEdit' );
}
}
@@ -1090,12 +1191,21 @@ abstract class classes_comments_renderer
/**
* Redirects to the latest comment
*
* @return void [Redirects]
* @param int Comment ID
* @param int Parent ID
* @param bool Did we just add a comment that requires approval?
* @return @e void [Redirects]
*/
public function redirectToComment( $commentId, $parentId )
public function redirectToComment( $commentId, $parentId, $showApprovalMessage=false )
{
/* Init */
$parentId = intval( $parentId );
if( !$parentId )
{
$this->registry->output->showError( 'nocomment_found', 110102.111 );
}
$parent = $this->fetchParent( $parentId );
$_remap = $this->remapKeys();
@@ -1103,7 +1213,7 @@ abstract class classes_comments_renderer
$parent = $this->remapFromLocal( $parent, 'parent' );
/* fetch */
$q = ( $this->can( 'moderate', array( 'comment_parent_id' => $parent['parent_id'] ) ) ) ? '' : ' AND ' . $_remap['comment_approved'] . '=1';
$q = ( $this->can( 'moderate', array( 'comment_parent_id' => $parent['parent_id'] ) ) === true ) ? '' : ' AND ' . $_remap['comment_approved'] . '=1';
/* Fetch comment */
if ( $commentId == 'last' )
@@ -1122,8 +1232,11 @@ abstract class classes_comments_renderer
'limit' => array( 0, 1 ) ) );
}
/* remap */
$comment = $this->remapFromLocal( $comment );
/* got a comment? */
if ( ! is_array( $comment ) )
{
$this->registry->output->silentRedirect( $this->settings['base_url'] . sprintf( $this->fetchSetting('urls-showParent', $parent), $parentId ) );
}
/* Permission test */
$can = $this->can('view', array( 'comment_id' => $comment['comment_id'], 'comment_parent_id' => $parentId ) );
@@ -1136,7 +1249,7 @@ abstract class classes_comments_renderer
/* Fetch total */
$total = $this->DB->buildAndFetch( array( 'select' => 'count(*) as total',
'from' => $this->table(),
'where' => $_remap['comment_parent_id'] . '=' . $parentId . $q . ' AND ' . $_remap['comment_id'] . '<=' . $comment['comment_id'] ) );
'where' => $_remap['comment_parent_id'] . '=' . $parentId . $q . ' AND ' . $_remap['comment_id'] . '<=' . intval( $comment[ $_remap['comment_id'] ] ) ) );
if ( $total['total'] > $this->perPage() )
{
@@ -1152,11 +1265,25 @@ abstract class classes_comments_renderer
$st = ($pages - 1) * $this->perPage();
$this->registry->output->silentRedirect( $this->settings['base_url'] . sprintf( $this->fetchSetting('urls-showParent', $parent), $parentId ) . "&st=" . $st . '#comment_' . $comment['comment_id'], $parent['parent_seo_title'], false, $this->seoTemplate() );
if( $showApprovalMessage )
{
$this->registry->output->redirectScreen( $this->lang->words['comment_approval_required'], $this->settings['base_url'] . sprintf( $this->fetchSetting('urls-showParent', $parent), $parentId ) . "&st=" . $st . '#comment_' . $comment[ $_remap['comment_id'] ], $parent['parent_seo_title'], $this->seoTemplate() );
}
else
{
$this->registry->output->silentRedirect( $this->settings['base_url'] . sprintf( $this->fetchSetting('urls-showParent', $parent), $parentId ) . "&st=" . $st . '#comment_' . $comment[ $_remap['comment_id'] ], $parent['parent_seo_title'], false, $this->seoTemplate() );
}
}
else
{
$this->registry->output->silentRedirect( $this->settings['base_url'] . sprintf( $this->fetchSetting('urls-showParent', $parent), $parentId ) . "#comment_" . $comment['comment_id'], $parent['parent_seo_title'], false, $this->seoTemplate() );
if( $showApprovalMessage )
{
$this->registry->output->redirectScreen( $this->lang->words['comment_approval_required'], $this->settings['base_url'] . sprintf( $this->fetchSetting('urls-showParent', $parent), $parentId ) . "&st=0#comment_" . $comment[ $_remap['comment_id'] ], $parent['parent_seo_title'], false, $this->seoTemplate() );
}
else
{
$this->registry->output->silentRedirect( $this->settings['base_url'] . sprintf( $this->fetchSetting('urls-showParent', $parent), $parentId ) . "&st=0#comment_" . $comment[ $_remap['comment_id'] ], $parent['parent_seo_title'], false, $this->seoTemplate() );
}
}
}
@@ -1165,8 +1292,8 @@ abstract class classes_comments_renderer
* Accepts a standard array of data
*
* @param array Array of GENERIC formatted data
* @return void
**/
* @return @e void
*/
public function remapToLocal( array $array, $type='comment' )
{
/* Return */
@@ -1176,7 +1303,7 @@ abstract class classes_comments_renderer
/* Please; continue */
foreach( $array as $k => $v )
{
if ( array_key_exists( $k, $_remap ) )
if ( isset( $_remap[ $k ] ) )
{
$return[ $_remap[ $k ] ] = $v;
}
@@ -1194,8 +1321,8 @@ abstract class classes_comments_renderer
* Accepts a standard array of data
*
* @param array Array of LOCAL data
* @return void
**/
* @return @e void
*/
public function remapFromLocal( array $array, $type='comment' )
{
/* Return */
@@ -1205,7 +1332,7 @@ abstract class classes_comments_renderer
/* Please; continue */
foreach( $array as $k => $v )
{
if ( array_key_exists( $k, $_remap ) )
if ( isset( $_remap[ $k ] ) )
{
$return[ $_remap[ $k ] ] = $v;
}
@@ -1227,6 +1354,26 @@ abstract class classes_comments_renderer
{
return '';
}
/**
* Section parsing for BBCode routines
*
* @return string
*/
public function bbcodeSection()
{
return 'global_comments';
}
/**
* Enable reputation?
*
* @return string
*/
public function reputationEnabled()
{
return true;
}
/**
* Number of items per page
@@ -1327,7 +1474,7 @@ abstract class classes_comments_renderer
* @param string Type of check (add/edit/delete/editall/deleteall/approve all)
* @param array Array of GENERIC data
* @return true or string to be used in exception
**/
*/
public function can( $type, array $array )
{
/* Default, so return least permissive */
@@ -1336,16 +1483,16 @@ abstract class classes_comments_renderer
/**
* Unpack the repuation cache, yo.
*
* @return void
* @return @e void
*/
protected function _unpackRepCache()
{
if ( $this->settings['reputation_enabled'] )
{
/* Load the class */
require_once( IPS_ROOT_PATH . 'sources/classes/class_reputation_cache.php' );
$this->registry->setClass( 'repCache', new classReputationCache() );
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/class_reputation_cache.php', 'classReputationCache' );
$this->registry->setClass( 'repCache', new $classToLoad() );
/* Update the filter? */
if( isset( $this->request['rep_filter'] ) && $this->request['rep_filter'] == 'update' )
{
@@ -1385,7 +1532,6 @@ abstract class classes_comments_renderer
/* Do some set up */
switch( $filters['sortKey'] )
{
default:
case 'post_date':
case 'date':
case 'time':
@@ -1395,6 +1541,13 @@ abstract class classes_comments_renderer
case 'author_id':
$filters['sortKey'] = 'comment_author_id';
break;
default:
if ( !$filters['sortKey'] )
{
$filters['sortKey'] = 'comment_date';
}
break;
}
switch( $filters['sortOrder'] )
@@ -1416,7 +1569,7 @@ abstract class classes_comments_renderer
$filters['offset'] = intval( $filters['offset'] );
$filters['limit'] = intval( $filters['limit'] );
$filters['unixCutOff'] = intval( $filters['unixCutOff'] );
/* Make sure we have a limit */
if ( ! $filters['limit'] )
{