/** * Builds an array of output for used in threaded view * * @access public * @param array $post * @param integer $depth * @return array **/ public function _threadedRenderListRow($post, $depth) { $post['depthguide'] = ""; $this->settings['post_showtext_notitle'] = 1; for ($i = 1; $i < $depth; $i++) { $post['depthguide'] .= $this->depth_guide[$i]; } // Last child? if ($depth > 0) { $last_id = count($this->structured_pids[$post['post_parent']]) - 1; if ($this->structured_pids[$post['post_parent']][$last_id] == $post['pid']) { $this->depth_guide[$depth] = '<img src="' . $this->settings['img_url'] . '/spacer.gif" alt="" width="20" height="16">'; $post['depthguide'] .= "<img src='" . $this->settings['img_url'] . "/to_post_no_children.gif' alt='-' />"; } else { $this->depth_guide[$depth] = '<img src="' . $this->settings['img_url'] . '/to_down_pipe.gif" alt="|" />'; $post['depthguide'] .= "<img src='" . $this->settings['img_url'] . "/to_post_with_children.gif' alt='-' />"; } } if (!$post['post_title']) { if ($this->settings['post_showtext_notitle']) { $post_text = IPSText::getTextClass('bbcode')->stripAllTags(strip_tags(IPSText::br2nl($post['post']))); if (IPSText::mbstrlen($post_text) > 50) { $post['post_title'] = IPSText::truncate($post_text, 50) . '...'; } else { $post['post_title'] = $post_text; } if (!trim($post['post_title'])) { $post['post_title'] = $this->lang->words['post_title_re'] . $this->topics->topic['title']; } } else { $post['post_title'] = $this->lang->words['post_title_re'] . $this->topics->topic['title']; } } $post['linked_name'] = IPSLib::makeProfileLink($post['author_name'], $post['author_id']); $post['formatted_date'] = $this->registry->class_localization->getDate($post['post_date'], 'LONG'); $post['new_post'] = 't_threaded_read'; if ($post['post_date'] > $this->topics->last_read_tid) { $post['new_post'] = 't_threaded_read'; } if (strstr($this->used_post_ids, ',' . $post['pid'] . ',')) { $post['_show_highlight'] = 1; } return $post; }
/** * Parase Topic Data * * @access public * @param array $topic Topic data * @param bool $last_time_default Use default "last read time" * @return array **/ public function parseTopicData($topic, $last_time_default = true) { //----------------------------------------- // INIT //----------------------------------------- $topic['real_tid'] = $topic['tid']; $topic['_last_post'] = $topic['last_post']; //----------------------------------------- // Do we have an SEO title? //----------------------------------------- $_hasSEOTitle = false; if ($topic['title_seo']) { $_hasSEOTitle = true; } $topic['title_seo'] = $topic['title_seo'] ? $topic['title_seo'] : IPSText::makeSeoTitle($topic['title']); /** * Here we'll take the one query hit to update in order to speed it up in the future */ if (!$_hasSEOTitle and $this->settings['use_friendly_urls']) { $this->DB->update('topics', array('title_seo' => $topic['title_seo'] ? $topic['title_seo'] : '-'), 'tid=' . $topic['tid']); } //----------------------------------------- // Need to update this topic? //----------------------------------------- if ($topic['state'] == 'open') { if (!$topic['topic_open_time'] or $topic['topic_open_time'] < $topic['topic_close_time']) { if ($topic['topic_close_time'] and ($topic['topic_close_time'] <= time() and (time() >= $topic['topic_open_time'] or !$topic['topic_open_time']))) { $topic['state'] = 'closed'; $this->update_topics_close[] = $topic['real_tid']; } } else { if ($topic['topic_open_time'] or $topic['topic_open_time'] > $topic['topic_close_time']) { if ($topic['topic_close_time'] and ($topic['topic_close_time'] <= time() and time() <= $topic['topic_open_time'])) { $topic['state'] = 'closed'; $this->update_topics_close[] = $topic['real_tid']; } } } } else { if ($topic['state'] == 'closed') { if (!$topic['topic_close_time'] or $topic['topic_close_time'] < $topic['topic_open_time']) { if ($topic['topic_open_time'] and ($topic['topic_open_time'] <= time() and (time() >= $topic['topic_close_time'] or !$topic['topic_close_time']))) { $topic['state'] = 'open'; $this->update_topics_open[] = $topic['real_tid']; } } else { if ($topic['topic_close_time'] or $topic['topic_close_time'] > $topic['topic_open_time']) { if ($topic['topic_open_time'] and ($topic['topic_open_time'] <= time() and time() <= $topic['topic_close_time'])) { $topic['state'] = 'open'; $this->update_topics_open[] = $topic['real_tid']; } } } } } //----------------------------------------- // For polls we check last vote instead // @todo [Future] Show a diff icon for new vote + new reply, new vote + no new reply, etc. // Bug 16598: Need separate checks for icon vs getnewpost link //----------------------------------------- if ($topic['poll_state'] and $topic['last_vote'] > $topic['last_post']) { $is_read = $this->registry->classItemMarking->isRead(array('forumID' => $topic['forum_id'], 'itemID' => $topic['tid'], 'itemLastUpdate' => $topic['last_vote']), 'forums'); $gotonewpost = $this->registry->classItemMarking->isRead(array('forumID' => $topic['forum_id'], 'itemID' => $topic['tid'], 'itemLastUpdate' => $topic['last_post']), 'forums'); } else { $is_read = $this->registry->classItemMarking->isRead(array('forumID' => $topic['forum_id'], 'itemID' => $topic['tid'], 'itemLastUpdate' => $topic['last_post']), 'forums'); $gotonewpost = $is_read; } //----------------------------------------- // Yawn //----------------------------------------- $topic['last_poster'] = $topic['last_poster_id'] ? IPSLib::makeProfileLink($topic['last_poster_name'], $topic['last_poster_id'], $topic['seo_last_name']) : $this->settings['guest_name_pre'] . $topic['last_poster_name'] . $this->settings['guest_name_suf']; $topic['starter'] = $topic['starter_id'] ? IPSLib::makeProfileLink($topic['starter_name'], $topic['starter_id'], $topic['seo_first_name']) : $this->settings['guest_name_pre'] . $topic['starter_name'] . $this->settings['guest_name_suf']; $topic['prefix'] = $topic['poll_state'] ? $this->registry->getClass('output')->getTemplate('forum')->topicPrefixWrap($this->settings['pre_polls']) : ''; $show_dots = ""; if ($this->memberData['member_id'] and (isset($topic['author_id']) and $topic['author_id'])) { $show_dots = 1; } $topic['folder_img'] = $this->registry->getClass('class_forums')->fetchTopicFolderIcon($topic, $show_dots, $is_read); /* SKINNOTE: Change these so that the link is built in the skin, not here */ $topic['topic_icon'] = $topic['icon_id'] ? '<img src="' . $this->settings['mime_img'] . '/style_extra/post_icons/icon' . $topic['icon_id'] . '.gif" border="0" alt="" />' : ' '; $topic['topic_icon'] = $topic['pinned'] ? '<{B_PIN}>' : $topic['topic_icon']; $topic['start_date'] = $this->registry->getClass('class_localization')->getDate($topic['start_date'], 'LONG'); //----------------------------------------- // Pages 'n' posts //----------------------------------------- $pages = 1; $topic['PAGES'] = ""; if ($this->memberData['is_mod']) { $topic['posts'] += intval($topic['topic_queuedposts']); } if ($topic['posts']) { $mode = IPSCookie::get('topicmode'); if ($mode == 'threaded') { $this->settings['display_max_posts'] = $this->settings['threaded_per_page']; } if (($topic['posts'] + 1) % $this->settings['display_max_posts'] == 0) { $pages = ($topic['posts'] + 1) / $this->settings['display_max_posts']; } else { $number = ($topic['posts'] + 1) / $this->settings['display_max_posts']; $pages = ceil($number); } } if ($pages > 1) { for ($i = 0; $i < $pages; ++$i) { $real_no = $i * $this->settings['display_max_posts']; $page_no = $i + 1; if ($page_no == 4 and $pages > 4) { $topic['pages'][] = array('last' => 1, 'st' => ($pages - 1) * $this->settings['display_max_posts'], 'page' => $pages); break; } else { $topic['pages'][] = array('last' => 0, 'st' => $real_no, 'page' => $page_no); } } } //----------------------------------------- // Format some numbers //----------------------------------------- $topic['posts'] = $this->registry->getClass('class_localization')->formatNumber(intval($topic['posts'])); $topic['views'] = $this->registry->getClass('class_localization')->formatNumber(intval($topic['views'])); //----------------------------------------- // Jump to latest post / last time stuff... //----------------------------------------- if (!$gotonewpost) { $topic['go_new_post'] = true; } else { $topic['go_new_post'] = false; } $topic['last_post'] = $this->registry->getClass('class_localization')->getDate($topic['last_post'], 'SHORT'); //----------------------------------------- // Linky pinky! //----------------------------------------- if ($topic['state'] == 'link') { $t_array = explode("&", $topic['moved_to']); $topic['tid'] = $t_array[0]; $topic['forum_id'] = $t_array[1]; $topic['title'] = $topic['title']; $topic['views'] = '--'; $topic['posts'] = '--'; $topic['prefix'] = $this->registry->getClass('output')->getTemplate('forum')->topicPrefixWrap($this->settings['pre_moved']); $topic['go_new_post'] = false; } else { $topic['_posts'] = $topic['posts']; $topic['posts'] = $this->registry->getClass('output')->getTemplate('forum')->who_link($topic['tid'], $topic['posts']); } $topic['_hasqueued'] = 0; $mod = $this->memberData['forumsModeratorData']; $mod = $mod ? $mod : array(); if (($this->memberData['g_is_supmod'] or $mod[$topic['forum_id']]['post_q'] and $mod[$topic['forum_id']]['post_q'] == 1) and $topic['topic_queuedposts']) { $topic['_hasqueued'] = 1; } //----------------------------------------- // Topic rating //----------------------------------------- $topic['_rate_img'] = ''; if (isset($this->forum['forum_allow_rating']) and $this->forum['forum_allow_rating']) { if ($topic['topic_rating_total']) { $topic['_rate_int'] = round($topic['topic_rating_total'] / $topic['topic_rating_hits']); } //----------------------------------------- // Show image? //----------------------------------------- if ($topic['topic_rating_hits'] >= $this->settings['topic_rating_needed'] and $topic['_rate_int']) { $topic['_rate_img'] = $this->registry->getClass('output')->getTemplate('forum')->topic_rating_image($topic['_rate_int']); } } //----------------------------------------- // Already switched on? //----------------------------------------- if ($this->memberData['is_mod']) { if ($this->request['selectedtids']) { if (strstr(',' . $this->request['selectedtids'] . ',', ',' . $topic['tid'] . ',')) { $topic['tidon'] = 1; } else { $topic['tidon'] = 0; } } } return $topic; }
/** * Formats the forum search result for display * * @access public * @param array $search_row Array of data from search_index * @param bool $isVnc Is from view new content * @return mixed Formatted content, ready for display, or array containing a $sub section flag, and content **/ public function formatContent($search_row, $isVnc = false) { /* Get class forums, used for displaying forum names on results */ if (ipsRegistry::isClassLoaded('class_forums') !== TRUE) { require_once IPSLib::getAppDir('forums') . "/sources/classes/forums/class_forums.php"; ipsRegistry::setClass('class_forums', new class_forums(ipsRegistry::instance())); ipsRegistry::getClass('class_forums')->forumsInit(); } /* Array */ $search_row = $this->_buildOutputArray($search_row); /* Indent */ $indent = $this->last_topic == $search_row['type_id_2']; $this->last_topic = $search_row['type_id_2']; /* Various data */ $search_row['_last_post'] = $search_row['last_post']; $search_row['_longTitle'] = $search_row['content_title']; $search_row['_shortTitle'] = IPSText::truncate($search_row['content_title'], 60); $search_row['last_poster'] = $search_row['last_poster_id'] ? IPSLib::makeProfileLink($search_row['last_poster_name'], $search_row['last_poster_id'], $search_row['seo_last_name']) : ipsRegistry::$settings['guest_name_pre'] . $search_row['last_poster_name'] . ipsRegistry::$settings['guest_name_suf']; $search_row['starter'] = $search_row['starter_id'] ? IPSLib::makeProfileLink($search_row['starter_name'], $search_row['starter_id'], $search_row['seo_first_name']) : $this->settings['guest_name_pre'] . $search_row['starter_name'] . $this->settings['guest_name_suf']; //$search_row['posts'] = ipsRegistry::getClass('class_localization')->formatNumber( intval($search_row['posts']) ); //$search_row['views'] = ipsRegistry::getClass('class_localization')->formatNumber( intval($search_row['views']) ); $search_row['last_post'] = ipsRegistry::getClass('class_localization')->getDate($search_row['last_post'], 'SHORT'); if (isset($search_row['post_date'])) { $search_row['_post_date'] = $search_row['post_date']; $search_row['post_date'] = ipsRegistry::getClass('class_localization')->getDate($search_row['post_date'], 'SHORT'); } if ($this->memberData['is_mod']) { $search_row['posts'] += intval($search_row['topic_queuedposts']); } if ($search_row['posts']) { if (($search_row['posts'] + 1) % ipsRegistry::$settings['display_max_posts'] == 0) { $pages = ($search_row['posts'] + 1) / ipsRegistry::$settings['display_max_posts']; } else { $number = ($search_row['posts'] + 1) / ipsRegistry::$settings['display_max_posts']; $pages = ceil($number); } } if ($pages > 1) { for ($i = 0; $i < $pages; ++$i) { $real_no = $i * ipsRegistry::$settings['display_max_posts']; $page_no = $i + 1; if ($page_no == 4 and $pages > 4) { $search_row['pages'][] = array('last' => 1, 'st' => ($pages - 1) * ipsRegistry::$settings['display_max_posts'], 'page' => $pages); break; } else { $search_row['pages'][] = array('last' => 0, 'st' => $real_no, 'page' => $page_no); } } } /* Format as a topic */ if ($search_row['type_2'] == 'topic') { /* Forum Breadcrum */ $search_row['_forum_trail'] = ipsRegistry::getClass('class_forums')->forumsBreadcrumbNav($search_row['forum_id']); /* Is it read? We don't support last_vote in search. */ $is_read = ipsRegistry::getClass('classItemMarking')->isRead(array('forumID' => $search_row['forum_id'], 'itemID' => $search_row['type_id_2'], 'itemLastUpdate' => $search_row['lastupdate'] ? $search_row['lastupdate'] : $search_row['updated']), 'forums'); /* Has posted dot */ $show_dots = ''; if (ipsRegistry::$settings['show_user_posted']) { if (ipsRegistry::member()->getProperty('member_id') && (isset($search_row['_topic_array'][$search_row['type_id_2']]) && $search_row['_topic_array'][$search_row['type_id_2']])) { $show_dots = 1; } } /* Icon */ $search_row['_icon'] = ipsRegistry::getClass('class_forums')->fetchTopicFolderIcon($search_row, $show_dots, $is_read); /* Display type */ if ($this->search_plugin->getShowAsForum() !== true) { return array(ipsRegistry::getClass('output')->getTemplate('search')->topicPostSearchResult($search_row, $indent, $this->search_plugin->onlyTitles || $this->search_plugin->noPostPreview ? 1 : 0), $indent); } else { return array(ipsRegistry::getClass('output')->getTemplate('search')->topicPostSearchResultAsForum($search_row, $indent, $this->search_plugin->onlyTitles || $this->search_plugin->noPostPreview ? 1 : 0), $indent); } } else { return ipsRegistry::getClass('output')->getTemplate('search')->forumSearchResult($search_row, $this->search_plugin->onlyTitles || $this->search_plugin->noPostPreview ? 1 : 0); } }