Leider sind meine php-Kenntnisse sehr rudimentär
Ich weiss nicht an welcher Stelle ich die if-Schleife einfügen muss, geschweige denn dat *else*-Dingens
Ich verwende die wec_discussion-Extension in Typo3.
Hier mal der Link zu meiner Testseite:
-> <edit> hab ich mal rausgenommen den Link </edit>
Hier das php-Skript der Extension (sry - das ist echt lang):
<?php
/***********************************************************************
* Copyright notice
*
* (c) 2005-2007 Foundation for Evangelism
* All rights reserved
*
* This file is part of the Web-Empowered Church (WEC)
* (http://www.webempoweredchurch.org) ministry of the Foundation for
* Evangelism (http://evangelize.org). The WEC is developing TYPO3-based
* (http://www.typo3.org) free software for churches around the world.
* Our desire is to use the Internet to help offer new life through
* Jesus Christ. Please see http://WebEmpoweredChurch.org/Jesus.
*
* You can redistribute this file and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation;
* either version 2 of the License, or (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This file is distributed in the hope that it will be useful for ministry,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the file!
*************************************************************************/
$ext_path = t3lib_extMgm::extPath('wec_discussion');
require_once(PATH_tslib.'class.tslib_pibase.php');
require_once(PATH_t3lib.'class.t3lib_basicfilefunc.php');
include_once($ext_path.'pi1/class.tx_wecdiscussion_convert.php');
/**
* Plugin 'WEC Discussion Forum' for the 'wec_discussion' extension.
*
* @author Web-Empowered Church Team <discussion@webempoweredchurch.org>
* @package TYPO3
* @subpackage wec_discussion
*
* "Do not let any unwholesome talk come out of your mouths, but only what
* is helpful for building others up according to their needs, that it may
* benefit those who listen." (Ephesians 4:29)
*
* DESCRIPTION:
* This extension allows you to add a discussion forum, blog, comments,
* preview or RSS feed to a page. This discussion system is simpler than a forum and
* is meant for one page. It can be used by one, a group, or all users.
*
* All the discussion types support one pages and multiple categories.
*
* The following are key differences in the discussion types:
* DISCUSSION: multiple categories / anyone can post or reply
* BLOG: only one person or a chosen group can add / anyone (or just users) can add a comment
* COMMENTS: anyone can add / just can add a comment (no replies to a message)
* PREVIEW: see last #N posts written / no post form
* RSS Feed: see XML feed / no other features
*
*/
class tx_wecdiscussion_pi1 extends tslib_pibase {
var $cObj; // The backReference to the mother cObj object set at call time
var $prefixId = 'tx_wecdiscussion_pi1'; // Same as class name
var $scriptRelPath = 'pi1/class.tx_wecdiscussion_pi1.php'; // Path to this script relative to the extension dir.
var $extKey = 'wec_discussion'; // The extension key.
var $wecAPI; // The WEC API class, if installed
var $postTable = 'tx_wecdiscussion_post';
var $groupTable = 'tx_wecdiscussion_group';
var $categoryTable = 'tx_wecdiscussion_category';
var $showDay; // date to be shown -- MMDDYY format
var $showDayTS; // date to be shown -- TIMESTAMP format
var $showCategory; // category to be shown
var $action; // action to do -- subscribe/unsubscribe/edit/etc.
var $editMsgNum; // message to be editted
var $filledInVars; // filled in for edit message
var $postvars; // post vars in wecdiscussion[var] format
var $submitFormResponse; // response text after submit form
var $formErrorText; // errors in form text
var $db_fields; // database fields (for processing)
var $marker; // global marker array
var $isAdministrator; // if is administrator/moderator
var $post_userlist; // list of users who can post
var $post_usergroup; // the user group who can post
var $isValidUser; // if restricted, if is valid user logged in; if unrestricted, then always valid
var $showPostForm; // if post form is available
var $showCommentForm; // if comment form is available
var $categoryList; // array list of all categories
var $categoryListByUID; // array list of all categories stored by uid
var $categoryCount; // total categories
var $freeCap; // for use by sr_freeCap image captcha
var $searchFieldList = 'name,email,subject,message,category';
var $searchWords; // words that are currently searching for
/**
* Init: Initialize the extension. read in Flexform/Typoscript/getvars.
*
* @param array $conf the TypoScript configuration
* @return void No return value needed.
*/
function init($conf) {
$GLOBALS['TSFE']->set_no_cache(); // don't want to cache this page since it is updated often
// $this->pi_USER_INT_obj = 1; // configure so caching not expected
// ------------------------------------------------------------
// Initialize vars, structures, arrays, etc.
// ------------------------------------------------------------
if (!$this->cObj) $this->cObj = t3lib_div::makeInstance('tslib_cObj');
$this->conf = $conf; // TypoScript configuration
$this->pi_setPiVarDefaults(); // GetPut-parameter configuration
$this->pi_initPIflexForm(); // Initialize the FlexForms array
$this->pi_loadLL(); // localized language variables
$this->templateName = 0;
$this->isAdministrator = 0;
$this->action = 0;
$this->formErrorText = 0;
$this->post_userlist = 0;
$this->post_usergroup = 0;
$this->db_fields = array('uid', 'name', 'email', 'subject', 'message', 'reply_uid', 'toplevel_uid', 'useruid', 'post_datetime', 'category', 'image', 'attachment');
$this->db_showFields = array('name', 'email', 'subject', 'message', 'category', 'image', 'attachment');
$this->id = $GLOBALS['TSFE']->id; // current page id
// ----------------------------------------------------------------------------------------
// Set USER Info->userGroups
// ----------------------------------------------------------------------------------------
if ($GLOBALS['TSFE']->loginUser) {
$this->userID = $GLOBALS['TSFE']->fe_user->user['uid'];
$this->userName = $GLOBALS['TSFE']->fe_user->user['username'];
$this->userFirstName = $GLOBALS['TSFE']->fe_user->user['first_name'];
$this->userGroups = $GLOBALS['TSFE']->fe_user->user['usergroup'];
if (strlen($this->userFirstName) < 1) $this->userFirstName = $this->userName;
$lastName = $GLOBALS['TSFE']->fe_user->user['last_name'];
if (strlen($lastName) > 0)
$this->userPostName = $this->userFirstName . ' ' . substr($lastName, 0, 1) . '.';
else
$this->userPostName = $this->userName;
} else {
// no user logged in...
$this->userID = 0;
$this->userName = '';
$this->userFirstname = '';
$this->userGroups = 0;
}
// set the storage PID (currently supports one page...could add recursive or multiple pages later)
//-------------------------------------------------------------
$this->config['storagePID'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'storagePID', 'sDEF');
if ($this->config['storagePID']) // can specify in flexform
$this->pid_list = $this->config['storagePID'];
else if ($this->conf['pid_list']) // or specify in TypoScript
$this->pid_list = $this->conf['pid_list'];
else {
$this->pid_list = $this->id; // the default is the current page
if (t3lib_div::_GP('wecdiscussion_inside'))
$this->pid_list = htmlspecialchars(t3lib_div::_GP('wecdiscussion_inside'));
}
// ------------------------------------------------------------
// Load in all flexform/Typoscript values
// ------------------------------------------------------------
$templateflex_file = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'template_file', 'sDEF');
$this->templateCode = $this->cObj->fileResource($templateflex_file ? "uploads/tx_wecdiscussion/".$templateflex_file: $this->conf['templateFile']);
// MAIN
$this->config['title'] = $this->getConfigVal($this, 'title', 'sDEF');
$this->config['type'] = $this->getConfigVal($this, 'type', 'sDEF');
$this->config['display_amount'] = $this->getConfigVal($this, 'display_amount', 'sDEF');
$this->config['restricted_userlist'] = trim($this->getConfigVal($this, 'restricted_userlist', 'sDEF'));
if (!empty($this->config['restricted_userlist'])) {
$this->post_userlist = t3lib_div::trimExplode(',', $this->config['restricted_userlist']);
}
$this->config['restricted_usergroup'] = trim($this->getConfigVal($this, 'restricted_usergroup', 'sDEF'));
// DISPLAY OPTIONS
$this->config['only_comments'] = $this->getConfigVal($this, 'only_comments', 's_options');
$this->config['reply_is_comment'] = $this->getConfigVal($this, 'reply_is_comment', 's_options');
$this->config['reply_level'] = $this->getConfigVal($this, 'reply_level', 's_options');
$this->config['allow_toggle_commentsreply'] = $this->getConfigVal($this, 'allow_toggle_commentsreply', 's_options');
$this->config['show_sidebar_actionbar'] = $this->getConfigVal($this, 'show_sidebar_actionbar', 's_options');
$this->config['allow_search'] = $this->getConfigVal($this, 'allow_search', 's_options');
$this->config['show_archive'] = $this->getConfigVal($this, 'show_archive', 's_options');
$this->config['show_chooseCat'] = $this->getConfigVal($this, 'show_chooseCat', 's_options');
$this->config['show_blank_subject'] = $this->getConfigVal($this, 'show_blank_subject', 's_options');
$this->config['display_characters_limit'] = $this->getConfigVal($this, 'display_characters_limit', 's_options');
$this->config['previewRSS_backPID'] = $this->getConfigVal($this, 'preview_backPID', 's_options');
$this->config['num_previewRSS_items'] = $this->getConfigVal($this, 'num_preview_items', 's_options');
$this->config['preview_length'] = $this->getConfigVal($this, 'preview_length', 's_options');
$this->config['preview_allow_replies'] = $this->getConfigVal($this, 'preview_allow_replies', 's_options');
// CONTROL OPTIONS
$this->config['is_moderated'] = $this->getConfigVal($this, 'is_moderated', 's_control');
$this->config['require_login_to_post'] = $this->getConfigVal($this, 'login_for_posting', 's_control');
$this->config['require_login_to_reply'] = $this->getConfigVal($this, 'login_for_reply', 's_control');
$this->config['require_login_to_subscribe'] = $this->getConfigVal($this, 'login_for_subscribing', 's_control');
$this->config['can_subscribe'] = $this->getConfigVal($this, 'can_subscribe', 's_control');
// SPAM
$this->config['html_tags_allowed'] = $this->getConfigVal($this, 'html_tags_allowed', 's_antispam');
$this->config['use_captcha'] = $this->getConfigVal($this, 'use_captcha', 's_antispam');
$this->config['use_text_captcha'] = $this->getConfigVal($this, 'use_text_captcha', 's_antispam');
$this->config['numlinks_allowed'] = $this->getConfigVal($this, 'numlinks_allowed', 's_antispam');
$this->config['filter_wordlist'] = $this->getConfigVal($this, 'filter_wordlist', 's_antispam');
$this->config['filter_word_handling'] = $this->getConfigVal($this, 'filter_word_handling', 's_antispam');
$this->config['only_check_comments'] = $this->getConfigVal($this, 'only_check_comments', 's_antispam');
// FIELDS
$this->config['required_fields'] = $this->getConfigVal($this, 'required_fields', 's_fields');
if (!empty($this->config['required_fields'])) {
$this->config['required_fields'] = t3lib_div::trimExplode(',', $this->config['required_fields']);
}
else
$this->config['required_fields'] = array('message');
$this->config['display_fields'] = $this->getConfigVal($this, 'display_fields', 's_fields');
if (!empty($this->config['display_fields']))
$this->config['display_fields'] = t3lib_div::trimExplode(',', $this->config['display_fields']);
else // use default fields...
$this->config['display_fields'] = array('name', 'email', 'subject', 'message', 'category');
// ADMIN
$this->config['administrator_group'] = $this->getConfigVal($this, 'administrator_group', 's_administrator');
$this->config['contact_name'] = $this->getConfigVal($this, 'contact_name', 's_administrator');
$this->config['contact_email'] = $this->getConfigVal($this, 'contact_email', 's_administrator');
$this->config['email_admin_posts'] = $this->getConfigVal($this, 'email_admin_posts', 's_administrator');
$this->config['notify_email'] = $this->getConfigVal($this, 'notify_email', 's_administrator');
// TEXT
$this->config['subscribe_header'] = $this->getConfigVal($this, 'subscribe_header', 's_text');
$this->config['subscriber_emailHeader'] = $this->getConfigVal($this, 'subscriber_emailHeader', 's_text');
$this->config['subscriber_emailFooter'] = $this->getConfigVal($this, 'subscriber_emailFooter', 's_text');
// SET administrator
//---------------------------------------------------
if ($this->userID && ($admins = $this->config['administrator_group'])) {
$adminList = t3lib_div::trimExplode(',', $admins);
foreach ($adminList as $thisAdmin) {
if (($thisAdmin == $this->userID) || ($thisAdmin == $this->userName)) {
$this->isAdministrator = 1;
break;
}
}
}
// Determine if a user who can post
//-----------------------------------------------------------------------
$this->isValidUser = 0;
// check if user on user list
for ($i = 0; $i < sizeof($this->post_userlist); $i++) {
$userident = $this->post_userlist[$i];
if (($this->userID && ((int) $userident == (int) $this->userID)) || (strcasecmp((string) $userident, $this->userName) == 0)) {
$this->isValidUser = 1;
break;
}
}
// check if user in usergroup
if (($restrictedGroup = $this->config['restricted_usergroup']) && $this->userID && $this->userGroups) {
$allGroupList = t3lib_div::trimExplode(',',$this->userGroups);
if ($allGroupList && in_array($restrictedGroup, $allGroupList)) {
$this->isValidUser = 1;
}
}
// no restricted users or usergroups
if (empty($this->config['restricted_userlist']) && empty($this->config['restricted_usergroup']))
$this->isValidUser = 1;
// Add captcha if loaded
//----------------------------------------------------------------------------
$this->freeCap = 0;
if ($this->config['use_captcha'] && t3lib_extMgm::isLoaded('sr_freecap')) {
require_once(t3lib_extMgm::extPath('sr_freecap').'pi2/class.tx_srfreecap_pi2.php');
$this->freeCap = t3lib_div::makeInstance('tx_srfreecap_pi2');
}
// SET UP DEFAULT VALUES FOR GIVEN TYPE
//----------------------------------------------------------------------------
switch ($this->config['type']) {
case 1: // discussion
$this->config['restricted_userlist'] = 0;
// user list is anyone
$this->config['reply_level'] = 3;
// allow post & replies (reply_level = 3)
$this->config['reply_is_comment'] = 0;
$this->config['only_comments'] = 0;
// anonymous OR reg. users can post/reply
$this->config['require_login_to_post'] = 0;
$this->config['require_login_to_reply'] = 0;
break;
case 2: // BLOG
// user list is restricted
$this->config['reply_level'] = 1;
$this->config['reply_is_comment'] = 1;
$this->config['only_comments'] = 0;
// only valid users can post
$this->config['require_login_to_post'] = 1;
$this->config['require_login_to_reply'] = 0;
break;
case 3: // COMMENTS
$this->config['restricted_userlist'] = 0; // user list is anyone
$this->config['reply_level'] = 0;
$this->config['reply_is_comment'] = 1;
$this->config['only_comments'] = 1;
$this->config['require_login_to_post'] = 0;
$this->config['require_login_to_reply'] = 0;
break;
case 4: // PREVIEW
// just show X number of items
// no need to set config vars...because all are ignored
break;
case 5:
// CUSTOM
// no overrides...whatever they want to set it as, they can.
break;
}
// *************************************************************************
// Check INCOMING POST Vars
// *************************************************************************
// read in postvars (i.e., tx_wecdiscussion[var1]...[var10]
//------------------
// if this is not a preview, then handle incoming vars
if (($this->config['type'] != 4) && ($this->config['type'] != 6) && ($this->config['type'] != 7)) {
$this->postvars = t3lib_div::GPvar('tx_wecdiscussion');
// // SECURITY: make sure the passed in vars are secure
// if (is_array($this->postvars)) {
// // should already be converted here...but if passing in bogus entries...will secure the <>
// foreach ($this->postvars as $pvKey => $pvVal) {
// $this->postvars[$pvKey] = str_replace('>', '>', $this->postvars[$pvKey]);
// $this->postvars[$pvKey] = str_replace('<', '<', $this->postvars[$pvKey]);
// }
// }
}
// ----------------------------------------------------------------------------------------
// Handle Passed-In values
// passed in: &tx_wecdiscussion[show_date] (date in MMDDYY format) and &tx_wecdiscussion[show_cat] (category ID)
// ----------------------------------------------------------------------------------------
// read, validate, and then setup curDay and curDayTS
$show_dateTime = $this->postvars['show_date'];
if (!is_numeric($show_dateTime) && $show_dateTime < 0)
unset($show_dateTime);
if (!isset($show_dateTime) || $show_dateTime == 0 || (strlen($show_dateTime) != 6) || !is_numeric($show_dateTime)) {
$this->showDayTS = mktime(); // return today() if not set or in correct format
$this->showDay = date('mdy');
} else {
$this->showDay = $show_dateTime;
$this->showDayTS = mktime(23, 59, 0, substr($show_dateTime, 0, 2), substr($show_dateTime, 2, 2), substr($show_dateTime, 4, 2));
}
// read, validate, and then setup showCategory
$curCategory = (int) $this->postvars['show_cat'];
if (!isset($curCategory) || !is_numeric($curCategory) || $curCategory < 0)
$curCategory = 0;
$this->showCategory = $curCategory;
//*************************************************************************
//
// LOAD IN CATEGORIES
//*************************************************************************
$where = 'pid IN('.$this->pid_list.')';
$where .= ' AND deleted=0 AND hidden=0';
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $this->categoryTable, $where, '', 'sort_order');
if (mysql_error()) t3lib_div::debug(array(mysql_error(), $res));
$this->categoryCount = 0;
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$this->categoryList[$this->categoryCount]['name'] = $row['name'];
$this->categoryList[$this->categoryCount]['image'] = $row['image'];
$this->categoryList[$this->categoryCount]['uid'] = $row['uid'];
$this->categoryListByUID[$row['uid']] = $row['name'];
$this->categoryCount++;
}
if ($this->showCategory != 0) {
// check for valid category UID
$found = false;
for ($i = 0; $i < $this->categoryCount; $i++) {
if ($this->showCategory == $this->categoryList[$i]['uid'])
$found = true;
}
if (!$found)
$this->showCategory = 0;
}
// POSTING/REPLYING TO FORUM OR EDITING EXISTING MESSAGE...
//----------------------------------------------------------
$replyForm = $this->postvars['replyForm'];
$canPost = (($this->config['require_login_to_post'] == 0) || ($this->userID != 0)) && $this->isValidUser;
$canPostReply = ($this->config['require_login_to_reply'] == 0) || ($this->userID != 0);
$this->showPostForm = !$this->config['only_comments'] && $canPost;
$this->showCommentForm = $canPostReply && ($this->config['reply_is_comment'] || $this->config['only_comments']);
if ((($replyForm == 1) && $this->showPostForm) ||
(($replyForm == 2) && $this->showCommentForm && (($this->postvars['reply_uid'] > 0) || $this->config['only_comments']))
&& !t3lib_div::_GP('ignore')) {
$this->postToForum($this->postvars);
}
// handle click on subscribing/unsubscribing
if (($thisSubAction = $this->postvars['sub']) != 0) {
// if coming from unsubscribing link in email
if (($thisSubAction == 2) && ($thisSubEmail = $this->postvars['email'])) {
$this->action = 'unsubscribe';
$this->unsubscribeFromGroup($thisSubEmail);
}
// make sure can subscribe and then allow
else if ($this->config['can_subscribe'] && (!$this->config['require_login_to_subscribe'] || $this->isAdministrator || $this->userID))
$this->action = 'subscribe';
}
// SHOWING ARCHIVE
//----------------------------------------------------------
if ($this->postvars['archive']) {
$this->config['display_amount'] = 2;
}
// SEARCH WORDS DEFINED...
//----------------------------------------------------------
if ($sw = $this->postvars['searchwords'])
$this->searchWords = $sw;
// DELETING POST FROM FORUM...
//----------------------------------------------------------
if ($this->postvars['deleteMsg'])
$this->deletePost($this->postvars['deleteMsg']);
// EDITTING POST FROM FORUM...
//----------------------------------------------------------
if ($this->postvars['editMsg']) {
$this->editMsgNum = $this->postvars['editMsg'];
if ($this->canEditPost($this->editMsgNum))
$this->action = 'edit';
else
$this->editMsgNum = 0;
}
// SUBMIT SUBSCRIBE REQUEST
//----------------------------------------------------------
if (t3lib_div::_GP('submitsubscribe')) {
if (!$this->subscribeToForum($this->postvars['email'])) {
// if unsuccessful, then go back to form
$this->action = 'subscribe';
}
}
// SUBMIT UNSUBSCRIBE REQUEST
//----------------------------------------------------------
if (t3lib_div::_GP('submitunsubscribe')) {
if (!$this->unsubscribeFromGroup($this->postvars['email'])) {
// if unsuccessful, then go back to form
$this->action = 'subscribe';
}
}
// MODERATE?
//----------------------------------------------------------
if ($this->postvars['moderate']) {
if ($this->isAdministrator)
$this->action = 'moderate';
}
// if moderated form being sent, then process the moderated now
if ($this->postvars['processmoderated'] && $this->isAdministrator) {
$this->processModerated(t3lib_div::_POST());
}
// RSS FEED?
//----------------------------------------------------------
if (($this->config['type'] == 6) ||
(($GLOBALS["TSFE"]->type == 224) && ($this->conf['rssFeedOn'] == 1))) { // RSS FEED
$this->action = 'rss';
}
// allow RSS feed to be "discovered" by feed readers
if (($this->conf['rssFeedOn'] == 1) && strcmp((string) $this->action,'rss')) {
$urlParam['type'] = 224;
$urlParam['sp'] = $this->pid_list;
$rssURL = $this->getAbsoluteURL($this->id,$urlParam);
$rssTitle = $this->conf['xml.']['rss.']['channel_title'] ? $this->conf['xml.']['rss.']['channel_title'] : ($this->config['title'] ? $this->config['title'] : 'RSS 2.0');
$GLOBALS['TSFE']->additionalHeaderData['tx_wecdiscussion'] = '<link rel="alternate" type="application/rss+xml" title="'.$rssTitle.'" href="'.$rssURL.'" />';
}
if ($this->config['type'] == 4) // force preview
$this->action = 'preview';
if ($this->config['type'] == 7) // only show archive
$this->action = 'archive';
// do timtab conversion?
$ttconvertNum = $this->conf['ttconvert'] ? $this->conf['ttconvert'] : 997;
if (!$this->action && (t3lib_div::_GET('ttconvert') == $ttconvertNum))
$this->action = 'ttconvert';
}
/**
* Main function: calls the init() function and decides by the given actions which functions to display content
*
* @param string $content : function output is added to this
* @param array $conf : TypoScript configuration array
* @return string $content: complete content generated by the plugin
*/
function main($content, $conf) {
$this->init($conf);
$content = '';
// do the given action set in init()
$this->action = (string) $this->action;
switch ($this->action) {
case 'edit':
$content .= $this->displayReplyForm($this->editMsgNum);
break;
case 'subscribe':
$content .= $this->displaySubscribeForm();
break;
case 'moderate':
$content .= $this->moderateMessages();
break;
case 'preview':
$content .= $this->displayPreview();
break;
case 'rss':
$content .= $this->displayRSSFeed();
return $content;
break;
case 'archive':
$content .= $this->displayArchive($this->showDateTS, 3);
return $content;
break;
case 'ttconvert':
$content = $this->adminConvert();
return $content;
break;
default:
$content .= $this->displayMain();
}
return $this->pi_wrapInBaseClass($content);
}
/**
* Displays main content: show the posts and reply form
*
* @return string $content: complete content generated by the plugin
*/
function displayMain() {
//
// Build each piece and then display
//-------------------------------------------------------------------------------
$subpartMarker = array();
// now read in the part of the template file with the PAGE subtemplatename
$template = $this->cObj->getSubpart($this->templateCode, '###TEMPLATE_PAGE###');
// generate the interface
$this->marker['###TITLE###'] = $this->config['title'];
$this->marker['###RESPONSE_MSG_TEXT###'] = $this->submitFormResponse;
// do not show sidebar?
if (($this->config['show_sidebar_actionbar'] == 1) || ($this->config['show_sidebar_actionbar'] == 3))
$subpartMarker['###SHOW_SIDEBAR###'] = '';
// do not show actionbar?
if (($this->config['show_sidebar_actionbar'] == 0) || ($this->config['show_sidebar_actionbar'] == 3))
$subpartMarker['###SHOW_ACTIONBAR###'] = '';
if ($this->config['can_subscribe'] && (!$this->config['require_login_to_subscribe'] || $this->isAdministrator || $this->userID)) {
$paramArray['tx_wecdiscussion[sub]'] = 1;
$subscribeBtn = '<a href="'.$this->pi_getPageLink($this->id, '', $paramArray).'">'.$this->pi_getLL('subscribe_btn', 'Subscribe').'</a>';
$this->marker['###SUBSCRIBE_BTN###'] = $subscribeBtn;
}
else
$subpartMarker['###SHOW_SUBSCRIBE_BTN##'] = '';
if ($this->isAdministrator && $this->config['is_moderated']) {
$paramArray = t3lib_div::_GET(); // get current vars and then add...
unset($paramArray['tx_wecdiscussion']['editMsg']);
unset($paramArray['tx_wecdiscussion']['processmoderated']);
$paramArray['tx_wecdiscussion']['moderate'] = 1;
$moderatorBtn = '<a href="'.$this->pi_getPageLink($this->id, '', $paramArray).'">'.$this->pi_getLL('moderate_btn', 'Moderate').'</a>';
$this->marker['###MODERATE_BTN###'] = $moderatorBtn;
}
else
$subpartMarker['###SHOW_MODERATE_BTN##'] = '';
// show 'post message' button at top if form is available
if ($this->showPostForm)
$this->marker['###POST_YOUR_MESSAGE_BTN###'] = $this->pi_getLL('post_your_message', 'Post Your Message');
else
$subpartMarker['###SHOW_POST_BTN###'] = "";
// show 'add comment' button at top if is only comments and form is available
if ($this->showCommentForm && $this->config['only_comments'])
$this->marker['###POST_YOUR_COMMENT_BTN###'] = $this->pi_getLL('add_comments','Add Your Comment');
else
$subpartMarker['###SHOW_COMMENT_BTN###'] = "";
if (!$this->submitFormResponse && !$this->showPostForm && !$this->showCommentForm) {
$this->marker['###RESPONSE_MSG_TEXT###'] = $this->pi_getLL('login_to_comment','<span style="color:black">You must login to post a message.</span>');
}
if ($this->postvars['single']) {
$goURL = $this->pi_getPageLink($this->id,'',$urlParams);
$this->marker['###DISPLAY_VIEW_ALL_BUTTON###'] = '<div class="tx-wecdiscussion-button" id="goback"><a href="'.$goURL.'">'.$this->pi_getLL('viewall_button','View All Messages').'</a></div>';
}
else
$this->marker['###DISPLAY_VIEW_ALL_BUTTON###'] = '';
// put up header for archive and category view
$showHeader = "";
if ($arch = $this->postvars['archive']) {
$archDate = $this->postvars['show_date'];
$archMonth = substr($archDate,0,2);
$showHeader .= $this->pi_getLL('header_archive','Archive for ').date($this->pi_getLL('archive_dateformat','F Y'),mktime(0,0,0,substr($archDate,0,2),substr($archDate,2,2),substr($archDate,4,2)));
}
if ($cat = $this->postvars['show_cat']) {
if (strlen($showHeader)) $showHeader .= $this->pi_getLL('header_separator',' / ');
$showHeader .= $this->categoryListByUID[$cat] . ' '.$this->pi_getLL('header_category','category');
}
if (strlen($showHeader))
$showHeader = $this->pi_getLL('header_tag_start','<h2>').$showHeader.$this->pi_getLL('header_tag_end','</h2>');
$this->marker['###DISPLAY_HEADER###'] = $showHeader;
// generate main content
$this->displayForum($this->showDayTS, $this->showCategory); // fills in ###DISPLAY_POSTS and ###DISPLAY_REPLIES
if ($this->config['show_archive']) {
// this must be after displayForum because expects certain vals set???
if (strstr($template,'###DISPLAY_ARCHIVE###'))
$subpartMarker['###SHOW_ARCHIVE###'] = $this->displayArchive($this->showDayTS);
if (strstr($template,'###DISPLAY_ARCHIVE_DROPDOWN###')) {
$this->marker['###ARCHIVE_HEADER###'] = $this->pi_getLL('archive_header', 'Archive:');
$this->marker['###DISPLAY_ARCHIVE_DROPDOWN###'] = $this->displayArchive($this->showDayTS, 2);
}
}
else {
$subpartMarker['###SHOW_ARCHIVE###'] = '';
$subpartMarker['###SHOW_ARCHIVE_DROPDOWN###'] = '';
}
// only show reply form if logged in (and valid user if a userlist) OR if don't care if logged in AND this is not a comment only
// if (!$this->config['only_comments'] && ($this->canPost || (!$this->config['reply_is_comment'] && $this->canPostReply)))
if ($this->showPostForm)
$this->marker['###DISPLAY_REPLYFORM###'] = $this->displayReplyForm();
// allow to have separate comment form (this can be hidden)
// if ($this->config['reply_is_comment'] && $this->canPostReply)
if ($this->showCommentForm)
$this->marker['###DISPLAY_COMMENTFORM###'] = $this->displayReplyForm(0, 1);
if ($this->config['show_chooseCat']) {
$this->marker['###CHOOSE_CATEGORY_VERTICAL###'] = $this->chooseCategory(1); // vertical list
$this->marker['###CHOOSE_CATEGORY_DROPDOWN###'] = $this->chooseCategory(2); // dropdown
}
// if sidebar is off and main content width constant is default, then make main content include sidebar width
// (this is the auto-configure dont-think/dummy code)
$mainContentWidth = $this->conf['mainContentWidth'];
if ((($this->config['show_sidebar_actionbar'] == 1) || ($this->config['show_sidebar_actionbar'] == 3)) &&
(!strcmp($mainContentWidth,'75%'))) {
$sidebarWidth = $this->conf['sidebarWidth'];
$mainContentWidth = (int)$mainContentWidth + (int) $sidebarWidth;
$mainContentWidth = (string) $mainContentWidth . '%';
}
$this->marker['###MAINCONTENT_WIDTH###'] = $mainContentWidth;
if ($this->config['allow_search']) {
$this->marker['###SEARCHFORM_URL###'] = $this->pi_getPageLink($this->id);
$this->marker['###SEARCHWORDS###'] = $this->searchWords;
$this->marker['###SEARCH_BUTTON###'] = $this->pi_getLL('search_btn', 'Search');
if ($this->searchWords) {
$this->marker['###DISPLAY_SEARCH_RESULTS###'] = $this->displaySearchResults($this->searchWords);
// clear out the other results/forms
$this->marker['###DISPLAY_POSTS###'] = '';
$this->marker['###DISPLAY_COMMENTS###'] = '';
$this->marker['###DISPLAY_REPLYFORM###'] = '';
$this->marker['###DISPLAY_COMMENTFORM###'] = '';
$subpartMarker['###SHOW_POST_BTN###'] = "";
}
}
else
$subpartMarker['###SHOW_SEARCH###'] = '';
// add RSS feed icon
$this->marker = $this->addSubscribeRSSFeed($this->marker);
// then substitute all the markers in the template into appropriate places
$content = $this->cObj->substituteMarkerArrayCached($template, $this->marker, $subpartMarker, array());
// clear out any empty template fields
$content = ereg_replace('###[A-Za-z_1234567890]+###', '', $content);
return $content;
}
/**
*==================================================================================
* Display forum --
*
* This allows multiple levels of replies or comments underneath each post.
* The posts can be sorted by date (most recent or least recent). They can also be
* viewed by a given category.
*
* The code is broken into 5 steps, and this method of doing it is done to try to
* minimize database access & allow flexibility.
*
* tx_wecdiscussion_post fields:
* post_datetime, post_lastedit_time, reply_uid, subject, message, category,
* image, image_caption, attachment
*
* @param integer the timestamp of the date to show
* @param integer the category to show (category ID)
* @return string content that contains the display of messages
*=====================================================================================
*/
function displayForum($showDateTS, $showCat) {
$forum_content = '';
$reply_content = '';
$fieldArray = $this->db_fields;
$subjCount = 0;
$single = $this->postvars['single'];
$template = $this->cObj->getSubpart($this->templateCode, '###TEMPLATE_DISPLAYENTRY###');
//-------------------------------------------------------------------------------------------------------
// 1. DETERMINE WHICH POSTS TO DISPLAY
// - based on time (WEEK / MONTH)
// - based on last X entries from given date
//
//-------------------------------------------------------------------------------------------------------
$selFields = '*';
$showDateTS = intval($showDateTS); // security check
$where = $this->setWhereDate($this->config['display_amount'], $showDateTS);
// set limit
$limit = '';
if ($this->config['display_amount'] == 3) $limit = '10';
else if ($this->config['display_amount'] == 4) $limit = '20';
else if ($this->config['display_amount'] == 5) $limit = '30';
//-------------------------------------------------------------------------------------------------------
//
// 2. LOAD ALL TOP-LEVEL POSTS FROM DATABASE FOR GIVEN DURATION & STORE THESE
//
// store in array message[topMsgUID][msgIndex][replies]
//-------------------------------------------------------------------------------------------------------
$order_by = 'post_datetime DESC';
if ($showCat) $where .= ' AND category='.intval($showCat);
$where .= ' AND toplevel_uid=0 ';
if ($single) $where = 'uid = '.$single;
$where .= ' AND pid IN('.$this->pid_list.')';
$where .= ' AND moderationQueue=0 AND deleted=0 AND hidden=0';
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($selFields, $this->postTable, $where, '', $order_by, $limit);
if (mysql_error()) t3lib_div::debug(array(mysql_error(), "SELECT ".$selFields.' FROM '.$this->postTable.' WHERE '.$where.' ORDER BY '.$order_by.' LIMIT '.$limit));
$count = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
$rootMsgUIDList = '';
// save all uids of root messages in a list
$rootMsgArray = array(); // save all uids in array too
if ($count == 0) {
// If no messages, give a message about none yet
if (!$this->postvars['show_cat'])
$noMessages = $this->pi_getLL('no_messages', 'No messages have been posted yet.');
// if no messages for a given category, give a message about none for that category
else
$noMessages = $this->pi_getLL('no_messages_for_category', 'No messages have been posted yet for this category.');
$this->marker['###DISPLAY_POSTS###'] = '<div class="tx-wecdiscussion-forumMessage">'.$noMessages.'</div>';
return;
}
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
// save all the top-level messages in a list and array
$subjCount++;
$thisUID = $row['uid'];
$rootMsgUIDList .= ($rootMsgUIDList == '') ? $thisUID : ",".$thisUID;
array_push($rootMsgArray, $thisUID);
// now save all the data
foreach ($fieldArray as $field) {
$message[$thisUID][0][$field] = $row[$field];
}
$message[$thisUID][0]['count'] = 1;
}
$params = t3lib_div::_GET();
$params['tx_wecdiscussion[show_date]'] = $this->showDay;
$pageID = $params['id'] ? $params['id'] : $GLOBALS['TSFE']->id;
unset($params['id']);
unset($params['tx_wecdiscussion']['archive']);
unset($params['tx_wecdiscussion']['processmoderated']);
unset($params['tx_wecdiscussion']['moderate']);
$gotoURL = $this->pi_getPageLink($pageID, '', $params);
//-------------------------------------------------------------------------------------------------------
//
// 3. LOAD ALL REPLY POSTS FROM DATABASE FOR GIVEN POSTS & STORE THESE
// Why we need to load the replies separately is because a reply might have been made weeks or
// months AFTER a given message is posted.
//
// This handles multi-level replies nested up to <X#> levels.
//
//-------------------------------------------------------------------------------------------------------
$order_by = 'toplevel_uid,reply_uid,post_datetime';
$where = 'toplevel_uid IN ('.$rootMsgUIDList.')';
$where .= ' AND moderationQueue=0 AND deleted=0 AND hidden=0 AND pid IN('.$this->pid_list.')';
if ($showCat)
$where .= ' AND category='.$showCat;
$limit = '';
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($selFields, $this->postTable, $where, '', $order_by, $limit);
if (mysql_error()) t3lib_div::debug(array(mysql_error(), "SELECT ".$selFields.' FROM '.$this->postTable.' WHERE '.$where.' ORDER BY '.$order_by.' LIMIT '.$limit));
$count = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
// pull out all reply messages and add them appropriately
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$topUID = $row['toplevel_uid'];
foreach ($rootMsgArray as $subj) {
if ($message[$subj][0]['uid'] == $topUID) {
$k = $message[$subj][0]['count'];
$message[$subj][0]['count']++;
break;
}
}
foreach ($fieldArray as $field) {
$message[$subj][$k][$field] = $row[$field];
}
}
//
// Add Javascript to handle replying for a post to the forum
//
// this will go to the form, set the reply value
$forum_content .= '
<script type="text/javascript">
//<![CDATA[
function makeReply(mNum,mNum2,mStr) {
if (sv = document.getElementById("subjValue"))
sv.value = mStr;
if (st = document.getElementById("subjTitle"))
st.innerHTML = "'.$this->pi_getLL("reply_field", "<b>Reply:</b>").'";
if (rud = document.getElementById("reply_uid_discussion"))
rud.value = mNum;
if (tud = document.getElementById("toplevel_uid_discussion"))
tud.value = mNum2;
return false;
}
function makeComment(mNum,mNum2) {
commentForm = document.getElementById("CommentFormToggle");
if (!commentForm) return false;
if (commentForm.style.display == "none")
commentForm.style.display = "block";
else
commentForm.style.display = "none";
if (rud = document.getElementById("reply_uid_comment"))
rud.value = mNum;
if (tud = document.getElementById("toplevel_uid_comment"))
tud.value = mNum2;
return false;
}
function deleteForumMsg(num) {
gotoURL = "'.t3lib_div::locationHeaderURL($gotoURL).'&tx_wecdiscussion[deleteMsg]="+num;
location.href = gotoURL;
}
function editForumMsg(num) {
gotoURL = "'.t3lib_div::locationHeaderURL($gotoURL).'&tx_wecdiscussion[editMsg]="+num;
location.href = gotoURL;
}
function clearReply() {
document.getElementById("reply_uid_discussion").value = 0;
document.getElementById("toplevel_uid_discussion").value = 0;
document.getElementById("subjValue").value = "";
document.getElementById("subjTitle").innerHTML = "'.$this->pi_getLL("subject_field", "Subject:").'";
// document.forumReplyForm.post_category.value = document.forumReplyForm.saved_category.value;
return false;
}
function showHideComment(num) {
cItem = document.getElementById(num);
if (cItem.style.display=="none")
cItem.style.display="block";
else
cItem.style.display="none";
return false;
}
function showHideItem(num) {
tItem = document.getElementById(num);
if (tItem.style.display=="none")
tItem.style.display="inline";
else
tItem.style.display="none";
return false;
}
//]]>
</script>
';
//-------------------------------------------------------------------------------------------------------
//
// 4. SORT THE MESSAGES TO DISPLAY
//
// Sort the messages according to categories & replies
//
// Can SORT BY most recent / oldest
//-------------------------------------------------------------------------------------------------------
$displayList = array();
foreach ($rootMsgArray as $subj) {
$subj = (int) $subj;
$toplevel_uid = $message[$subj][0]['uid'];
$totalMsgs = $message[$subj][0]['count'];
$message[$subj][0]['level'] = 0;
array_push($displayList, $message[$subj][0]);
for ($i = 1; $i < $totalMsgs; $i++) {
// if top level, then add
if ($message[$subj][$i]['reply_uid'] == $toplevel_uid) {
$message[$subj][$i]['level'] = 1;
array_push($displayList, $message[$subj][$i]);
// then find all on SECOND level
for ($j = 1; $j < $totalMsgs; $j++) {
if ($message[$subj][$j]['reply_uid'] == $message[$subj][$i]['uid']) {
$message[$subj][$j]['level'] = 2;
array_push($displayList, $message[$subj][$j]);
// then find all on THIRD level
for ($k = 1; $k < $totalMsgs; $k++) {
$message[$subj][$k]['level'] = 3;
if ($message[$subj][$k]['reply_uid'] == $message[$subj][$j]['uid']) {
array_push($displayList, $message[$subj][$k]);
}
}
}
}
}
}
}
//-------------------------------------------------------------------------------------------------------
//
// 5. DISPLAY MESSAGES
//
// Format and show the messages. The formatting can be determined by the template.
//
// format: <Text>
// Posted by: <Name> <Date> [REPLY] | [DELETE]
//-------------------------------------------------------------------------------------------------------
$templateDisplayContent = $this->cObj->getSubpart($this->templateCode, '###TEMPLATE_DISPLAYENTRY###');
$postTemplateEntry = $GLOBALS['TSFE']->cObj->getSubpart($templateDisplayContent, '###POST_ENTRY###');
$replyTemplateEntry = $GLOBALS['TSFE']->cObj->getSubpart($templateDisplayContent, '###REPLY_ENTRY###');
$waitForToggle = 0;
$topLevelUID = 0;
for ($i = 0; $i < sizeof($displayList); $i++) {
unset($markerArray);
$msg = $displayList[$i];
$nextMsg = ($i < (sizeof($displayList) - 1)) ? $displayList[$i+1] :
0; // peek ahead for determining comment toggle
if ($msg['reply_uid'] == 0) {
// if this is not a reply, then set this as a toplevel message
$topLevelUID = $msg['uid'];
$thisTemplateEntry = $postTemplateEntry;
} else {
// this is a reply...
$thisTemplateEntry = $replyTemplateEntry;
}
$msgLeftMargin = 0;
for ($k = 0; $k < $msg['level']; $k++)
$msgLeftMargin += 25;
if ($msgLeftMargin)
$markerArray['###MARGIN_LEFT###'] = 'style="padding-left:'.$msgLeftMargin.'px"';
if (strlen($msg['subject']) == 0) {
// if subject is blank, then...
if ($this->config['show_blank_subject']) // put a space so will show up
$msg['subject'] = $this->pi_getLL('no_subject', ' ');
else {
// clear out subject area
$thisTemplateEntry = $this->cObj->substituteSubpart($thisTemplateEntry, '###SHOW_SUBJECT###', '');
}
}
// SHOW THE MESSAGE
//------------------------------------------------------------
$postName = stripslashes($msg['name']);
$postName = (strlen($postName) > 0) ? $postName : $this->pi_getLL('no_user', 'Anonymous');
$postEmail = stripslashes($msg['email']);
$markerArray['###SUBJECT###'] = stripslashes($msg['subject']);
$urlParams['tx_wecdiscussion']['single'] = $msg['uid'];
$singleLinkStart = '<a href="'.$this->pi_getPageLink($GLOBALS['TSFE']->id,'',$urlParams).'">';
if (!$single && (($this->conf['singleViewLink'] == 'subject') || ($this->conf['singleViewLink'] == 'subject_and_view'))) {
$markerArray['###VIEW_SINGLE_LINKSTART###'] = $singleLinkStart;
$markerArray['###VIEW_SINGLE_LINKEND###'] = '</a>';
}
if (!$single && (($this->conf['singleViewLink'] == 'view_link') || ($this->conf['singleViewLink'] == 'subject_and_view')))
$markerArray['###VIEW_SINGLE###'] = $this->pi_getLL('action_separator', '|') . $singleLinkStart . $this->pi_getLL('view_single','View') . '</a>';
// for message text, either allow HTML, only certain tags or no HTML
$msgText = stripslashes($msg['message']);
$tagsAllowed = $this->config['html_tags_allowed'];
// if tags allowed set and either comment or NOT only_check_comments
if (strlen($tagsAllowed) && (($msg['toplevel_uid'] != 0) || !$this->config['only_check_comments'] || !$this->userID)) {
$msgText = $this->html_entity_decode($msgText);
if ($tagsAllowed != 1 && strlen($tagsAllowed)) {
$msgText = strip_tags($msgText,$tagsAllowed);
}
}
// if message is greater than character limit, then put MORE...
if (!$single && ($charLimit = $this->config['display_characters_limit']) && (strlen($msgText) > $charLimit)) {
$msgToSee = substr($msgText,0,$charLimit);
$msgToSeeRev = strrev($msgToSee);
// grab message up to length and find first space or special tag (search from end of string).
$tagList = array('<ol' ,'<a', '<link', '<div', '<p', '<ul');
$endTagList = array('/ol>','/a>','/link>','/div>','/p>','/ul>');
$maxDist = 0;
// we search for all the tags and find the closest one
for ($t = 0; $t < count($tagList); $t++) {
$kEnd = 0;
if ($findTag = strpos($msgToSeeRev,strrev($tagList[$t]))) {
$k = strlen($msgToSee) - ($findTag + strlen($tagList[$t]) + 1);
if ($tagEnd = strpos($msgToSeeRev,strrev($endTagList[$t])))
$kEnd = strlen($msgToSee) - ($tagEnd + strlen($endTagList[$t]) +1);
if (($k > $maxDist) && (!$kEnd || ($kEnd > $k)))
$maxDist = $k;
// if in middle of tag, go to beginning of tag
if ($kEnd && ($kEnd < $k)) {
if ($kEnd > $maxDist)
$maxDist = $kEnd + strlen($endTagList[$t]);
}
}
}
// if no tags found, then find first period or exclamation point
if ($maxDist == 0) {
$k = strrpos($msgToSee,'.') + 1;
$k2 = strrpos($msgToSee,'!') + 1;
if ($k2 > $k) $k = $k2;
if ($k <= 1)
$k = strrpos($msgToSee,' ') + 1;
}
else
$k = $maxDist + 1;
$msgToSee = substr($msgText,0, $k);
$msgToHide = substr($msgText, $k, strlen($msgText) - $k);
$msgID = 'MSG'.$msg['uid'];
$moreID = 'MORE'.$msg['uid'];
$msgText = $msgToSee . '<span id="'.$moreID.'" style="display:inline;"><a href="#" onclick="showHideItem(\''.$moreID.'\'); return showHideItem(\''.$msgID.'\');"> '.$this->pi_getLL('more','More...').'</a></span> <div id="'.$msgID.'" style="display:none;">'.$this->pi_getLL('more_bridge','...').$msgToHide.'</div>';
}
// format message with general_stdWrap from TS config
if (is_array($this->conf['general_stdWrap.'])) {
$msgText = $this->cObj->stdWrap($msgText, $this->conf['general_stdWrap.']);
}
$markerArray['###MESSAGE###'] = $msgText;
$markerArray['###POST_NAME###'] = $postName;
$markerArray['###POST_DATE###'] = strftime($this->pi_getLL('date_format', '%b %e, %Y'), $msg['post_datetime']);
$markerArray['###POST_DATETIME###'] = strftime($this->pi_getLL('datetime_format', '%b %e, %Y %H:%M%p'), $msg['post_datetime']);
$markerArray['###ATTACHMENT###'] = $msg['attachment'];
$markerArray['###POSTEDBY_TEXT###'] = $this->pi_getLL('posted_by', 'Posted By:');
$markerArray['###ON_TEXT###'] = $this->pi_getLL('on_text', 'on');
// if there is an email, put it in an encrypted link, otherwise just put the name
$markerArray['###POST_NAME_EMAILLINK###'] = strlen($postEmail) ? '<a href="javascript:linkTo_UnCryptMailto(\''.$GLOBALS['TSFE']->encryptEmail('mailto:'.$postEmail).'\');">'.$postName.'</a>' : $postName;
$markerArray['###IMAGE###'] = $msg['image'] ? $this->getImageURL($msg['image']) : '';
if ($msg['attachment']) {
$attachFile = 'uploads/tx_wecdiscussion/'.$msg['attachment'];
$attachMsg = $this->pi_getLL('attached_file', 'Attached File: ')." <a href=\"".$attachFile."\">".$msg['attachment'].'</a>';
$markerArray['###ATTACHMENT###'] = $attachMsg;
}
else
$markerArray['###ATTACHMENT###'] = '';
if ($msg['category']) {
$paramArrayCat['tx_wecdiscussion[show_cat]'] = $msg['category'];
$gotoURL = $this->pi_getPageLink($GLOBALS['TSFE']->id, '', $paramArrayCat);
$markerArray['###CATEGORY###'] = $this->pi_getLL('category_title', 'Category:').'<a href='.$gotoURL.'>'.$this->categoryListByUID[$msg['category']].'</a>';
} else {
$thisTemplateEntry = $this->cObj->substituteSubpart($thisTemplateEntry, '###SHOW_CATEGORY###', '');
}
// add a view comment button (unless viewing single, then show all comments)
$msg['view_commentreply'] = 0;
if (($this->config['reply_level'] > 0) && $this->config['allow_toggle_commentsreply'] && !$this->postvars['single']) {
// go through and find the right top level message and add a "view comment" if there are comments for this message
foreach ($rootMsgArray as $topMsgUID) {
if (($message[$topMsgUID][0]['uid'] == $msg['uid']) && ($message[$topMsgUID][0]['count'] > 1)) {
$viewCommentStr = $this->pi_getLL('view_comments', 'View Comments').' ['.($message[$topMsgUID][0]['count']-1).']';
$markerArray['###VIEW_COMMENTS###'] = $this->pi_getLL('action_separator', '|') . ' <a href="#" onclick="return showHideComment(\'CMMT'.$msg['uid'].'\');return false;">'.$viewCommentStr.'</a>';
$msg['view_commentreply'] = 1;
$numComments = $message[$topMsgUID][0]['count']-1;
$markerArray['###VIEW_COMMENTS_NUM###'] = $this->pi_getLL('viewcommentnum_start').$numComments.$this->pi_getLL('viewcommentnum_end');
break;
}
}
}
// allow to add show/hide button tag for any message content
$markerArray['###TOGGLE_HIDE_START_ON###'] = '<div id="MSG'.$msg['uid'].'" style="display:block;">';
$markerArray['###TOGGLE_HIDE_START_OFF###'] = '<div id="MSG'.$msg['uid'].'" style="display:none;">';
$markerArray['###TOGGLE_HIDE_LINK###'] = '<div id="MSGOFF'.$msg['uid'].'" style="display:inline;"><a href="#" onclick="showHideItem(\'MSGOFF'.$msg['uid'].'\'); return showHideComment(\'MSG'.$msg['uid'].'\');">'.$this->pi_getLL('show_toggle','View').'</a></div>';
$markerArray['###TOGGLE_HIDE_ONCLICK###'] = 'showHideComment(\'MSG'.$msg['uid'].'\'); return false;';
$markerArray['###TOGGLE_HIDE_END###'] = '</div>';
// Add a reply button
//-----------------------------------------------------------------------
if ($msg['level'] < $this->config['reply_level']) {
$mSubj = 'RE:'.$msg['subject'];
$params = t3lib_div::_GET();
$params['tx_wecdiscussion[show_date]'] = $this->showDay;
$pageID = $params['id'] ? $params['id'] : $GLOBALS['TSFE']->id;
unset($params['id']);
unset($params['tx_wecdiscussion']['archive']);
$gotoURL = $this->pi_getPageLink($pageID, '', $params);
if ($this->showCommentForm) {
$btnName = $this->pi_getLL('comment_btn', 'Add Comment');
$replyUID = $msg['uid'];
if ($this->config['reply_level'] == 0) {
// if no parent messages, then keep msgs at same level
$replyUID = 0;
$topLevelUID = 0;
}
$btnStr = '<a href="#" onclick="javascript:makeComment('.$replyUID.','.$topLevelUID.');window.location.hash=\'typeYourComment\';return false;">'.$btnName.'</a>';
} else if ($this->showPostForm) {
$btnName = $this->pi_getLL('reply_btn', 'Reply');
$btnStr = '<a href="#" onclick="makeReply('.$msg['uid'].','.$topLevelUID.',\''.$mSubj.'\');window.location.hash=\'typeYourMessage\';return false;">'.$btnName.'</a>';
}
$markerArray['###REPLY_BTN###'] = $btnStr;
}
else
$markerArray['###REPLY_BTN###'] = '';
// Add an edit/delete button if this user is the author or if is admin
//------------------------------------------------------------------------
if (($GLOBALS['TSFE']->loginUser) && (($msg['useruid'] == $this->userID) || ($this->isAdministrator))) {
$markerArray['###EDIT_BTN###'] = " | <a href=\"#\" onclick=\"editForumMsg(".$msg['uid']."); return false;\">".$this->pi_getLL('edit_btn', 'Edit').'</a>';
$markerArray['###DELETE_BTN###'] = " | <a href=\"#\" onclick=\"deleteForumMsg(".$msg['uid']."); return false;\">".$this->pi_getLL('delete_btn', 'Delete').'</a>';
}
// now substitute all the marker arrays in the template
//-------------------------------------------------------------------------
$msg_content = $this->cObj->substituteMarkerArrayCached($thisTemplateEntry, $markerArray, array(), array());
// Handle showHideComment for comments div
//--------------------------------------------------------------------------
// if we are in toggle comments section AND next msg i
