/**
  * Lists all posts in a certain topic.
  * @param  string $content The plugin content
  * @param  array $conf The plugin's configuration vars
  * @param $order
  * @return string          The content
  */
 function list_post($content, $conf, $order)
 {
     $templateFile = $this->local_cObj->fileResource($conf['template.']['list_post']);
     $topicId = intval($this->piVars['tid']);
     $feUserId = intval($GLOBALS['TSFE']->fe_user->user['uid']);
     // Check authorization
     if (!$this->getMayRead_topic($topicId)) {
         return $this->errorMessage($conf, $this->pi_getLL('topic.noAccess'));
     }
     $topicData = $this->getTopicData($topicId);
     $this->tx_mmforum_rss->setHTMLHeadData('forum', $topicData['forum_id']);
     $this->tx_mmforum_rss->setHTMLHeadData('topic', $topicId);
     $this->local_cObj->data = $topicData;
     // Save admin panel changes
     $this->saveAdminChanges($topicData);
     // Determine sorting mode
     $orderingMode = $conf['list_posts.']['postOrdering'] ? strtoupper($conf['list_posts.']['postOrdering']) : 'ASC';
     $order = strtoupper($order);
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['forum']['listPost_order'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['forum']['listPost_order'] as $_classRef) {
             $_procObj =& GeneralUtility::getUserObj($_classRef);
             $order = $_procObj->listPost_order($order, $this);
         }
     }
     if (in_array($order, array('ASC', 'DESC'))) {
         $orderingMode = $order;
     }
     if (!in_array($orderingMode, array('ASC', 'DESC'))) {
         $orderingMode = 'ASC';
     }
     // load the topic data again, to make sure we get the latest additions from the admin changes
     $topicData = $this->getTopicData($topicId);
     // check and set the topic replies
     $res = $this->databaseHandle->exec_SELECTquery('COUNT(*)-1', 'tx_mmforum_posts', 'deleted = 0 AND topic_id = ' . $topicId . $this->getStoragePIDQuery());
     list($replies) = $this->databaseHandle->sql_fetch_row($res);
     $updateArray = array('topic_replies' => $replies);
     $this->databaseHandle->exec_UPDATEquery('tx_mmforum_topics', 'uid = ' . $topicId, $updateArray);
     // Set or unset solved flag
     if (isset($this->piVars['solved'])) {
         if ($topicData['topic_poster'] == $feUserId || $this->getIsAdmin() || $this->getIsMod($topicData['forum_id'])) {
             $this->set_solved($topicId, $this->piVars['solved']);
             $this->piVars['pid'] = 'last';
         } else {
             $content .= '<script type="text/javascript">alert(\'' . $this->pi_getLL('topic.noSolveRights') . '\')</script>';
         }
         unset($this->piVars['solved']);
     }
     // redirect to a specific post
     if ($this->piVars['pid']) {
         $this->redirectToReply($topicId, $this->piVars['pid']);
     }
     // generate the marker for the admin panel
     if (!$conf['slimPostList']) {
         $adminPanel = $this->getAdminPanel($topicData);
     } else {
         $adminPanel = '';
     }
     // Output post listing START
     $template = $this->local_cObj->getSubpart($templateFile, empty($conf['LIST_POSTS_BEGIN']) ? '###LIST_POSTS_BEGIN###' : $conf['LIST_POSTS_BEGIN']);
     $marker = array('###LABEL_AUTHOR###' => $this->pi_getLL('post.author'), '###LABEL_MESSAGE###' => $this->pi_getLL('post.message'), '###ADMIN_PANEL###' => $adminPanel);
     if ($conf['slimPostList']) {
         $template = $this->local_cObj->substituteSubpart($template, '###HEADER_SUBPART###', '');
         $template = $this->local_cObj->substituteSubpart($template, '###ROOTLINE_CONTAINER###', '');
     }
     // Log if topic has been read since last visit
     if ($feUserId) {
         $res = $this->databaseHandle->exec_SELECTquery('COUNT(uid) AS read_flg', 'tx_mmforum_postsread', 'topic_id = ' . $topicId . ' AND user = '******'pid' => $this->getStoragePID(), 'topic_id' => $topicId, 'user' => $feUserId, 'tstamp' => $GLOBALS['EXEC_TIME'], 'crdate' => $GLOBALS['EXEC_TIME']);
             $this->databaseHandle->exec_INSERTquery('tx_mmforum_postsread', $insertArray);
         }
     }
     // Increase hit counter
     $this->databaseHandle->exec_UPDATEquery('tx_mmforum_topics', 'uid = ' . $topicId, array('topic_views' => 'topic_views+1'), 'topic_views');
     // Generate page navigation
     $limitCount = $conf['post_limit'];
     $marker['###PAGES###'] = $this->pagecount('tx_mmforum_posts', 'topic_id', $topicId, $limitCount);
     // Generate breadcrumb menu
     if ($conf['disableRootline']) {
         $template = $this->local_cObj->substituteSubpart($template, '###ROOTLINE_CONTAINER###', '');
     } else {
         $marker['###FORUMPATH###'] = $this->get_forum_path($topicData['forum_id'], $topicId);
     }
     $marker['###PAGETITLE###'] = $this->local_cObj->data['header'];
     $marker['###TOPICICON###'] = $this->getTopicIcon($topicId);
     // Retrieve topic data again
     $topicData = $this->getTopicData($topicId);
     $this->local_cObj->data = $topicData;
     // Determine page number
     if ($this->piVars['page']) {
         $pageNum = $this->piVars['page'];
         if ($conf['doNotUsePageBrowseExtension']) {
             $pageNum++;
         }
     } elseif ($this->piVars['search_pid']) {
         $res = $this->databaseHandle->exec_SELECTquery('uid', 'tx_mmforum_posts', 'deleted = 0 AND hidden = 0 AND topic_id = ' . $topicId . $this->getStoragePIDQuery(), '', 'post_time ' . $orderingMode);
         $i = 0;
         $pageNum = 0;
         while ($row = $this->databaseHandle->sql_fetch_assoc($res)) {
             $i++;
             if ($row['uid'] == $this->piVars['search_pid']) {
                 $pageNum = $i / $limitCount;
             }
         }
         $pageNum = intval($pageNum);
     } else {
         $pageNum = 0;
     }
     $forumpath_topic = $this->escape(stripslashes($topicData['topic_title']));
     $topic_is = $topicData['topic_is'];
     $closed = $this->local_cObj->cObjGetSingle($conf['list_posts.']['closed'], $conf['list_posts.']['closed.']);
     $prefix = $this->local_cObj->cObjGetSingle($conf['list_posts.']['prefix'], $conf['list_posts.']['prefix.']);
     // Check if solved flag is set
     // TODO: add marker to template
     if ($topicData['solved'] == 1) {
         $imgInfo = array('src' => $conf['path_img'] . $conf['images.']['solved'], 'alt' => $this->pi_getLL('topic.isSolved'), 'style' => 'vertical-align: middle;');
         $solvedIcon = $this->buildImageTag($imgInfo);
     } else {
         $solvedIcon = '';
     }
     // Output topic name
     $marker['###TOPICNAME###'] = $closed . $forumpath_topic;
     $marker['###TOPICPREFIX###'] = strtolower($prefix);
     $marker['###PREFIX###'] = $prefix;
     /* Display the topic rating if the 'ratings' extension is installed
      * and topic rating is enabled. */
     $isTopicRating = $this->isTopicRating();
     if ($isTopicRating) {
         $marker['###TOPIC_RATING###'] = $isTopicRating ? $this->getRatingDisplay('tx_mmforum_topic', $topicData['uid']) : '';
     } else {
         $template = $this->local_cObj->substituteSubpart($template, '###SUBP_TOPIC_RATING###', '');
     }
     // Display poll
     if ($topicData['poll_id'] > 0 && $pageNum == 0 && $conf['polls.']['enable']) {
         $tx_mmforum_polls = GeneralUtility::makeInstance('tx_mmforum_polls');
         $marker['###POLL###'] = $tx_mmforum_polls->display($topicData['poll_id']);
     } else {
         $marker['###POLL###'] = '';
     }
     // Include hooks
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['display']['listPosts_topic'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['display']['listPosts_topic'] as $_classRef) {
             $_procObj =& GeneralUtility::getUserObj($_classRef);
             $marker = $_procObj->listPosts_topic($marker, $topicData, $this);
         }
     }
     $content .= $this->local_cObj->substituteMarkerArray($template, $marker);
     // Determine last answering date to allow a user to edit his entry
     $res = $this->databaseHandle->exec_SELECTquery('MAX(post_time)', 'tx_mmforum_posts', 'deleted = 0 AND hidden = 0 AND topic_id = ' . $topicId . $this->getStoragePIDQuery());
     list($lastpostdate) = $this->databaseHandle->sql_fetch_row($res);
     $topicData['_v_last_post_date'] = $lastpostdate;
     $DoNotSelectFirstPost = '';
     if (intval($this->firstPostID) > 0) {
         $DoNotSelectFirstPost = ' AND uid <> ' . intval($this->firstPostID);
     }
     $postList = $this->databaseHandle->exec_SELECTquery('*', 'tx_mmforum_posts', 'deleted = 0 AND hidden = 0 AND topic_id = ' . $topicId . $this->getStoragePIDQuery() . $DoNotSelectFirstPost, '', 'post_time ' . $orderingMode, $limitCount * $pageNum . ', ' . $limitCount);
     if ($this->databaseHandle->sql_num_rows($postList) == 0 && $pageNum > 0) {
         $linkParams[$this->prefixId] = array('action' => 'list_post', 'tid' => $topicId, 'page' => $pageNum);
         $link = $this->pi_getPageLink($GLOBALS['TSFE']->id, '', $linkParams);
         HttpUtility::redirect($link);
     }
     $templateItem = trim($this->local_cObj->getSubpart($templateFile, '###LIST_POSTS###'));
     $templateFirst = trim($this->local_cObj->getSubpart($templateFile, '###LIST_POSTS_FIRST###'));
     $i = 1;
     while ($row = $this->databaseHandle->sql_fetch_assoc($postList)) {
         $postMarker = $this->getPostListMarkers($row, $topicData, array('even' => $i++ % 2 == 0));
         $postMarker['###ADMIN_PANEL###'] = $adminPanel;
         if ($row['uid'] == $topicData['topic_first_post_id'] && $templateFirst) {
             $content .= $this->local_cObj->substituteMarkerArrayCached($templateFirst, $postMarker);
         } else {
             $content .= $this->local_cObj->substituteMarkerArrayCached($templateItem, $postMarker);
         }
     }
     // Output post listing END
     $templateOptions = $this->local_cObj->getSubpart($templateFile, '###LIST_POSTS_OPTIONEN###');
     $template = $this->local_cObj->getSubpart($templateFile, empty($conf['LIST_POSTS_END']) ? '###LIST_POSTS_END###' : $conf['LIST_POSTS_END']);
     if (!$topicData['read_flag'] && !$topicData['closed_flag'] || $this->getIsMod($topicData['forum_id']) || $this->getIsAdmin()) {
         if ($this->getMayWrite_topic($topicId)) {
             $linkParams[$this->prefixId] = array('action' => 'new_post', 'tid' => $topicId);
             if ($this->useRealUrl()) {
                 $linkParams[$this->prefixId]['fid'] = $topicData['forum_id'];
             }
             $marker['###POSTBOTTOM###'] = $this->createButton('reply', $linkParams);
         } else {
             $marker['###POSTBOTTOM###'] = '';
         }
     } else {
         $marker['###POSTBOTTOM###'] = $this->pi_getLL('topic.adminsOnly');
     }
     if ($feUserId) {
         $marker['###POSTMAILLINK###'] = $this->getSubscriptionButton($topicId, $topicData);
         $marker['###FAVORITELINK###'] = $this->getFavoriteButton($topicId, $topicData);
         $marker['###SOLVEDLINK###'] = $this->getSolvedButton($topicId, $topicData);
         if ($topicData['topic_poster'] == $feUserId || $this->getIsAdmin() || $this->getIsMod($topicData['forum_id'])) {
             $linkParams[$this->prefixId] = array('action' => 'list_post', 'tid' => $topicId);
             $marker['###SOLVED_ACTION###'] = '';
             $marker['###LABEL_THISTOPICIS###'] = $this->pi_getLL('topic.thisTopicIs');
             $marker['###LABEL_NOTSOLVED###'] = $this->pi_getLL('topic.notSolved');
             $marker['###LABEL_SOLVED###'] = $this->pi_getLL('topic.solved');
             $marker['###LABEL_SAVE###'] = $this->pi_getLL('save');
             $marker['###SOLVED_FALSE###'] = !$topicData['solved'] ? 'selected="selected"' : '';
             $marker['###SOLVED_TRUE###'] = $topicData['solved'] ? 'selected="selected"' : '';
             $marker['###SOLVED_TOPICUID###'] = $topicId;
             $marker['###ACTION###'] = $this->piVars['action'];
             $marker['###FORMACTION###'] = $this->escapeURL($this->pi_getPageLink($GLOBALS['TSFE']->id));
         } else {
             $template_option = $this->cObj->substituteSubpart($templateOptions, '###SOLVEDOPTION###', '');
         }
         $marker['###LABEL_OPTIONS###'] = $this->pi_getLL('options');
         $marker['###POST_OPTIONEN###'] = $this->cObj->substituteMarkerArray($templateOptions, $marker);
     } else {
         $marker['###POST_OPTIONEN###'] = '';
     }
     // Include hooks
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['display']['listPosts_footer'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['display']['listPosts_footer'] as $_classRef) {
             $_procObj =& GeneralUtility::getUserObj($_classRef);
             $marker = $_procObj->listPosts_footer($marker, $topicData, $this);
         }
     }
     $content .= $this->local_cObj->substituteMarkerArray($template, $marker);
     return $content;
 }
Ejemplo n.º 2
0
 /**
  * Lists all topics in a certain board.
  * @param  string $content The plugin content
  * @param  array  $conf    The plugin's configuration vars
  * @return string          The content
  */
 function list_topic($content, $conf)
 {
     $feUserId = intval(isset($GLOBALS['TSFE']->fe_user->user['uid']) ? $GLOBALS['TSFE']->fe_user->user['uid'] : 0);
     $forumId = intval($this->piVars['fid']);
     $imgInfo = array('border' => $conf['img_border'], 'alt' => '', 'src' => '', 'style' => '');
     // Checking the forum for read access
     if (!$this->getMayRead_forum($forumId)) {
         $content .= $this->errorMessage($conf, $this->pi_getLL('board.noAccess'));
         return $content;
     }
     $templateFile = $this->cObj->fileResource($conf['template.']['list_topic']);
     $template = $this->cObj->getSubpart($templateFile, '###TOPICBEGIN###');
     $marker = array();
     // find out the unread posts since the last login
     $res = $this->databaseHandle->exec_SELECTquery('uid', 'tx_mmforum_forums', 'uid = ' . $forumId . $this->getStoragePIDQuery());
     if ($this->databaseHandle->sql_num_rows($res) == 0) {
         $content .= $this->errorMessage($conf, $this->pi_getLL('board.noAccess'));
         return $content;
     }
     // load the forum details for the header
     list($rowForum) = $this->databaseHandle->exec_SELECTgetRows('*', 'tx_mmforum_forums', 'uid = ' . $forumId . $this->getStoragePIDQuery());
     if (empty($rowForum['grouprights_read'])) {
         $this->tx_mmforum_rss->setHTMLHeadData('forum', $forumId);
     }
     if ($this->conf['disableRootline']) {
         $template = $this->cObj->substituteSubpart($template, '###ROOTLINE_CONTAINER###', '');
     } else {
         $marker['###FORUMPATH###'] = $this->get_forum_path($forumId, '');
     }
     $marker['###PAGETITLE###'] = $this->cObj->data['header'];
     $marker['###FORUMNAME###'] = $this->escape($rowForum['forum_name']);
     $marker['###FORUMDESC###'] = $this->escape($rowForum['forum_desc']);
     $marker['###FORUMICON###'] = $this->getForumIcon($rowForum, $this->getMayRead_forum($rowForum), FALSE);
     $linkParams[$this->prefixId] = array('action' => 'new_topic', 'fid' => $forumId);
     $imgInfo['src'] = $conf['path_img'] . $this->getLanguageFolder() . $conf['images.']['new_topic'];
     if ($this->getMayWrite_forum($forumId)) {
         $marker['###NEWTOPICLINK###'] = $this->createButton('newtopic', $linkParams);
     } else {
         $marker['###NEWTOPICLINK###'] = '';
     }
     $isTopicRating = $this->isTopicRating();
     if (!$isTopicRating) {
         $template = $this->cObj->substituteSubpart($template, '###SUBP_RATING_LABEL###', '');
     }
     $marker['###LABEL_TOPIC###'] = $this->pi_getLL('board.topic');
     $marker['###LABEL_REPLIES_HITS###'] = $this->pi_getLL('board.replies');
     $marker['###LABEL_AUTHOR###'] = $this->pi_getLL('board.author');
     $marker['###LABEL_LASTPOST###'] = $this->pi_getLL('board.lastPost');
     $marker['###LABEL_HIDESOLVED###'] = $this->pi_getLL('board.hideSolved');
     $marker['###LABEL_RATING###'] = $this->pi_getLL('board.rating');
     $limitcount = $conf['topic_count'];
     $marker['###MARKREAD###'] = $this->getMarkAllRead_link();
     // List of the pages as a page browser
     $marker['###PAGES###'] = $this->pagecount('tx_mmforum_topics', 'forum_id', $forumId, $limitcount);
     $marker['###HIDESOLVED_CHECKED###'] = $this->piVars['hide_solved'] ? 'checked="checked"' : '';
     $marker['###SETTINGS_ACTION###'] = htmlspecialchars($this->pi_linkTP_keepPIvars_url(array('hide_solved' => 0)));
     // Include hooks
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['forum']['listTopics_header'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['forum']['listTopics_header'] as $_classRef) {
             $_procObj =& GeneralUtility::getUserObj($_classRef);
             $marker = $_procObj->listTopics_header($marker, $this, $rowForum);
         }
     }
     $content .= $this->cObj->substituteMarkerArray($template, $marker);
     // load the posts that the user set as "favorites"
     $userFav = '';
     if ($feUserId) {
         $userFav = $this->get_user_fav();
     }
     $currentPage = intval($this->piVars['page']) > 0 ? intval($this->piVars['page']) : 0;
     if ($this->conf['doNotUsePageBrowseExtension']) {
         $currentPage++;
     }
     $limit = ($limitcount - 1) * $currentPage . ',' . $limitcount;
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['forum']['listTopics_limit'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['forum']['listTopics_limit'] as $_classRef) {
             $_procObj =& GeneralUtility::getUserObj($_classRef);
             $limit = $_procObj->listTopics_limit($limitcount, $currentPage, $this);
         }
     }
     $solvedCon = $this->piVars['hide_solved'] ? ' AND t.solved=0 ' : '';
     $shadowCon = $this->conf['enableShadows'] ? '' : ' AND t.shadow_tid=0 ';
     // load all the posts
     $topiclist = $this->databaseHandle->exec_SELECTquery('t.*', 'tx_mmforum_topics t, tx_mmforum_posts p', 'p.uid = t.topic_last_post_id AND ' . 't.deleted = 0 AND t.hidden = 0 AND t.forum_id = ' . $forumId . $solvedCon . $shadowCon . $this->getStoragePIDQuery('t'), '', 't.at_top_flag DESC, p.post_time DESC', $limit);
     if ($this->databaseHandle->sql_num_rows($topiclist) > 0) {
         $template = $this->cObj->getSubpart($templateFile, '###LIST_TOPIC###');
     } else {
         $template = $this->cObj->getSubpart($templateFile, '###LIST_NOTOPIC###');
         $content .= $this->cObj->substituteMarker($template, '###LABEL_NOTOPICS###', $this->pi_getLL('topic.noTopicsFound'));
     }
     if (!$isTopicRating) {
         $template = $this->cObj->substituteSubpart($template, '###SUBP_RATING###', '');
     }
     $j = 1;
     $topics = array();
     $topicIds = array();
     while ($row = $this->databaseHandle->sql_fetch_assoc($topiclist)) {
         $topics[] = $row;
         $topicIds[] = $row['uid'];
     }
     //get tuhe unread state _of only the 30 (or so) topics per page and not that _of all posts_
     $conf['topic_id'] = $topicIds;
     $readarray = array();
     if ($GLOBALS['TSFE']->fe_user->user['uid']) {
         $lastlogin = $GLOBALS['TSFE']->fe_user->user['tx_mmforum_prelogin'];
         $readarray = $this->getunreadposts($content, $conf, $lastlogin);
     }
     /*
      * MAIN LOOP begin
      */
     foreach ($topics as $row) {
         // Check if solved flag is set.
         $solved = '';
         $favorit = '';
         if ($row['solved'] == 1 && $this->conf['topicIconMode'] == 'classic') {
             $imgInfo['src'] = $conf['path_img'] . $conf['images.']['solved'];
             $imgInfo['alt'] = $this->pi_getLL('topic.isSolved');
             $imgInfo['title'] = $this->pi_getLL('topic.isSolved');
             $solved = $this->buildImageTag($imgInfo);
         }
         // Check if the topic is favorite
         if (is_array($userFav) && in_array($row['uid'], $userFav)) {
             $imgInfo['src'] = $conf['path_img'] . $conf['images.']['favorite'];
             $imgInfo['alt'] = $this->pi_getLL('topic.isFavorite');
             $imgInfo['title'] = $this->pi_getLL('topic.isFavorite');
             $favorit = $this->buildImageTag($imgInfo);
         }
         $topic_is = $row['topic_is'] ? $this->cObj->wrap($row['topic_is'], $this->conf['list_topics.']['prefix_wrap']) : '';
         if ($row['shadow_tid'] == 0) {
             $linkParams[$this->prefixId] = array('action' => 'list_post', 'tid' => $row['uid']);
             if ($this->useRealUrl()) {
                 $linkParams[$this->prefixId]['fid'] = $row['forum_id'];
             }
         } else {
             $linkParams[$this->prefixId] = array('action' => 'list_post', 'tid' => $row['shadow_tid']);
             if ($this->useRealUrl()) {
                 $linkParams[$this->prefixId]['fid'] = $row['shadow_fid'];
             }
             $topic_is = $this->cObj->wrap($this->pi_getLL('topic.shadow'), $this->conf['list_topics.']['prefix_wrap']);
         }
         $marker['###TOPICNAME###'] = $favorit . $topic_is . '<a href="' . htmlspecialchars($this->pi_getPageLink($GLOBALS['TSFE']->id, '', $linkParams)) . '" title="' . $this->escape($row['topic_title']) . '">' . $this->escape($this->cObj->stdWrap($row['topic_title'], $this->conf['list_topics.']['topicTitle_stdWrap.'])) . '</a> ' . $solved;
         $page_link = '';
         $last_post_link = '';
         // Display page navigation below topic name, making it possible to jump to a page directly
         if ($row['topic_replies'] + 1 > $conf['post_limit']) {
             $page_link = '( ' . $this->pi_getLL('page.goto') . ':';
             $menge = $row['topic_replies'] + 1;
             $i = 1;
             $pages = ceil($menge / $conf['post_limit']);
             $interval = ceil($pages / 10);
             for ($i = 0; $i < $pages; $i += $interval) {
                 $linkParams[$this->prefixId] = array('action' => 'list_post', 'tid' => $row['uid'], 'page' => $i);
                 if ($linkParams[$this->prefixId]['page'] < 1) {
                     $linkParams[$this->prefixId]['page'] = '';
                 }
                 $page_link .= ' ' . $this->pi_linkToPage($i + 1, $GLOBALS['TSFE']->id, '', $linkParams);
                 if ($interval > 1) {
                     if ($i == $interval + 1) {
                         $i--;
                     }
                 }
                 if ($i == $pages) {
                     break;
                 }
                 if ($i + $interval > $pages) {
                     $i = $pages - $interval;
                 }
             }
             $page_link .= ' ) ';
             $marker['###TOPICNAME###'] .= $this->cObj->wrap($page_link, $this->conf['list_topics.']['pagenav_wrap']);
         }
         $linkParams[$this->prefixId]['pid'] = 'last';
         $imgInfo['src'] = $conf['path_img'] . $conf['images.']['jump_to'];
         $imgInfo['alt'] = $this->pi_getLL('topic.gotoLastPost');
         $imgInfo['title'] = $this->pi_getLL('topic.gotoLastPost');
         $last_post_link = $this->pi_linkToPage($this->buildImageTag($imgInfo), $GLOBALS['TSFE']->id, '', $linkParams);
         $replies = intval($row['topic_replies']);
         $marker['###HITS###'] = $row['shadow_tid'] == 0 ? $row['topic_views'] : '-';
         $marker['###POSTS###'] = $row['shadow_tid'] == 0 ? $replies : '';
         $marker['###POSTS_HITS###'] = $row['shadow_tid'] == 0 ? $replies . ' (' . $row['topic_views'] . ')' : '';
         $marker['###AUTHOR###'] = $this->getauthor($row['topic_poster']);
         $marker['###LAST###'] = $this->getlastpost($row['topic_last_post_id'], $conf) . ' ' . $last_post_link;
         $marker['###LIST_TOPIC_EVENODD###'] = $this->conf['display.']['listItem.'][($j++ % 2 ? 'odd' : 'even') . 'Class'];
         $marker['###RATING###'] = $isTopicRating ? $this->getRatingDisplay('tx_mmforum_topic', $row['uid']) : '';
         // display last answer (and a no-replies message if there is only the initial thread post)
         if ($replies > 0) {
             $marker['###LASTREPLY###'] = $this->getlastpost($row['topic_last_post_id'], $conf) . ' ' . $last_post_link;
         } else {
             $marker['###LASTREPLY###'] = $this->pi_getLL('topic.noreplies');
         }
         // Get topic icon
         $marker['###READIMAGE###'] = $this->getTopicIcon($row, $readarray);
         // Include hooks
         if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['forum']['listTopics_topicItem'])) {
             foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['forum']['listTopics_topicItem'] as $_classRef) {
                 $_procObj =& GeneralUtility::getUserObj($_classRef);
                 $marker = $_procObj->listTopics_topicItem($marker, $row, $this, $conf);
             }
         }
         $content .= $this->cObj->substituteMarkerArrayCached($template, $marker);
     }
     /*
      * MAIN LOOP end
      */
     $template = $this->cObj->getSubpart($templateFile, '###TOPICEND###');
     $marker['###PAGES###'] = $this->pagecount('tx_mmforum_topics', 'forum_id', $forumId, $limitcount);
     // Include hooks
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['forum']['listTopics_footer'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['forum']['listTopics_footer'] as $_classRef) {
             $_procObj =& GeneralUtility::getUserObj($_classRef);
             $marker = $_procObj->listTopics_footer($marker, $this, $rowForum);
         }
     }
     $content .= $this->cObj->substituteMarkerArray($template, $marker);
     // Added by Cyrill Helg
     if ($feUserId) {
         $template = $this->cObj->getSubpart($templateFile, '###LIST_POSTS_OPTIONEN###');
         $res = $this->databaseHandle->exec_SELECTquery('uid', 'tx_mmforum_forummail', 'user_id = ' . $feUserId . ' AND forum_id = ' . $forumId . $this->getStoragePIDQuery());
         if ($this->databaseHandle->sql_num_rows($res) < 1) {
             $imgInfo['alt'] = $this->pi_getLL('topic.emailSubscr.off');
             $imgInfo['title'] = $this->pi_getLL('topic.emailSubscr.off');
             $imgInfo['src'] = $conf['path_img'] . $conf['images.']['info_mail_off'];
             $linkParams[$this->prefixId] = array('action' => 'set_havealookforum', 'fid' => $forumId);
             // if ($this->useRealUrl()) $linkParams[$this->prefixId]['fid'] = $postforum;
             //TODO: This does not work yet
             $link = $this->pi_linkTP($this->pi_getLL('on'), $linkParams) . ' / <strong>' . $this->pi_getLL('off') . '</strong>';
             $image = $this->pi_linkTP($this->buildImageTag($imgInfo), $linkParams);
         } else {
             $imgInfo['alt'] = $this->pi_getLL('topic.emailSubscr.on');
             $imgInfo['title'] = $this->pi_getLL('topic.emailSubscr.on');
             $imgInfo['src'] = $conf['path_img'] . $conf['images.']['info_mail_on'];
             $linkParams[$this->prefixId] = array('action' => 'del_havealookforum', 'fid' => $forumId);
             // if ($this->useRealUrl()) $linkParams[$this->prefixId]['fid'] = $postforum;
             //TODO: This does not work yet
             $link = '<strong>' . $this->pi_getLL('on') . '</strong> / ' . $this->pi_linkTP($this->pi_getLL('off'), $linkParams);
             $image = $this->pi_linkTP($this->buildImageTag($imgInfo), $linkParams);
         }
         // 			$image = $this->buildImageTag($imgInfo);
         $image = $this->cObj->stdWrap($image, $this->conf['list_posts.']['optImgWrap.']);
         $link = $this->cObj->stdWrap($link, $this->conf['list_posts.']['optLinkWrap.']);
         $marker['###POSTMAILLINK###'] = $this->cObj->stdWrap($image . $link, $this->conf['list_posts.']['optItemWrap.']);
         $marker['###LABEL_OPTIONS###'] = $this->pi_getLL('options_mail_forum');
         $content .= $this->cObj->substituteMarkerArray($template, $marker);
     }
     return $content;
 }