本文整理匯總了PHP中IPSText::searchHighlight方法的典型用法代碼示例。如果您正苦於以下問題:PHP IPSText::searchHighlight方法的具體用法?PHP IPSText::searchHighlight怎麽用?PHP IPSText::searchHighlight使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類IPSText
的用法示例。
在下文中一共展示了IPSText::searchHighlight方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: calendarShowEvent
/**
* Show a single event based on eventid
*
* @return @e void
*/
public function calendarShowEvent()
{
//-----------------------------------------
// Init
//-----------------------------------------
$event_id = intval($this->request['event_id']);
if (!$event_id) {
$this->registry->output->showError('calendar_event_not_found', 10429, null, null, 404);
}
//-----------------------------------------
// Get the event data
//-----------------------------------------
$_joins = array(array('select' => 'm.*', 'from' => array('members' => 'm'), 'where' => 'm.member_id=e.event_member_id', 'type' => 'left'), array('select' => 'pp.*', 'from' => array('profile_portal' => 'pp'), 'where' => 'm.member_id=pp.pp_member_id', 'type' => 'left'));
if ($this->settings['reputation_enabled']) {
$classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/class_reputation_cache.php', 'classReputationCache');
$this->registry->setClass('repCache', new $classToLoad());
$_joins[] = $this->registry->getClass('repCache')->getTotalRatingJoin('event_id', $event_id, 'calendar');
$_joins[] = $this->registry->getClass('repCache')->getUserHasRatedJoin('event_id', $event_id, 'calendar');
}
$event = $this->DB->buildAndFetch(array('select' => 'e.*', 'from' => array('cal_events' => 'e'), 'where' => 'e.event_id=' . $event_id, 'add_join' => $_joins));
if (!$event['event_id']) {
$this->registry->output->showError('calendar_event_not_found', 10430, null, null, 404);
}
//-----------------------------------------
// Reset calendar
//-----------------------------------------
$this->calendar = $this->functions->getCalendar($event['event_calendar_id']);
if ($this->calendar['cal_id'] != $event['event_calendar_id']) {
$this->registry->output->showError('cal_no_perm', 1040.22, null, null, 403);
}
//-----------------------------------------
// Check permissions
//-----------------------------------------
if ($event['event_private'] and $this->memberData['member_id'] != $event['event_member_id']) {
$this->registry->output->showError('calendar_event_not_found', 10431, null, null, 403);
}
if (!$this->memberData['g_is_supmod'] and !$event['event_approved']) {
$this->registry->output->showError('calendar_event_not_found', 10432.1, null, null, 404);
}
if ($event['event_perms'] != '*') {
$permissionGroups = explode(',', IPSText::cleanPermString($event['event_perms']));
if (!IPSMember::isInGroup($this->memberData, $permissionGroups)) {
$this->registry->output->showError('calendar_event_not_found', 10432, null, null, 404);
}
}
//-----------------------------------------
// Are we RSVPing?
//-----------------------------------------
if ($this->request['_rsvp'] and $event['event_rsvp']) {
if ($this->registry->permissions->check('rsvp', $this->calendar) and $this->memberData['member_id']) {
//-----------------------------------------
// Make sure we aren't already RSVPed
//-----------------------------------------
$_check = $this->DB->buildAndFetch(array('select' => 'rsvp_id', 'from' => 'cal_event_rsvp', 'where' => 'rsvp_event_id=' . $event['event_id'] . ' AND rsvp_member_id=' . $this->memberData['member_id']));
if (!$_check['rsvp_id']) {
$_insert = array('rsvp_event_id' => $event['event_id'], 'rsvp_member_id' => $this->memberData['member_id'], 'rsvp_date' => time());
$this->DB->insert('cal_event_rsvp', $_insert);
$this->registry->output->redirectScreen($this->lang->words['rsvp_saved_im'], $this->settings['base_url'] . "app=calendar&module=calendar&section=view&do=showevent&event_id=" . $event['event_id'], $event['event_title_seo'], 'cal_event');
}
}
}
//-----------------------------------------
// Comments class
//-----------------------------------------
require_once IPS_ROOT_PATH . 'sources/classes/comments/bootstrap.php';
/*noLibHook*/
$this->_comments = classes_comments_bootstrap::controller('calendar-events');
$comments = array('html' => $this->_comments->fetchFormatted($event, array('offset' => intval($this->request['st']))), 'count' => $this->_comments->count($event));
//-----------------------------------------
// Highlight...
//-----------------------------------------
if ($this->request['hl']) {
$event['event_content'] = IPSText::searchHighlight($event['event_content'], $this->request['hl']);
$event['event_title'] = IPSText::searchHighlight($event['event_title'], $this->request['hl']);
}
//-----------------------------------------
// Can we report?
//-----------------------------------------
$classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('core') . '/sources/classes/reportLibrary.php', 'reportLibrary', 'core');
$reports = new $classToLoad($this->registry);
$event['_canReport'] = $reports->canReport('calendar');
//-----------------------------------------
// Output
//-----------------------------------------
$member = IPSMember::load($event['event_member_id'], 'all');
$this->registry->output->addNavigation($this->calendar['cal_title'], "app=calendar&module=calendar&section=view&cal_id={$this->calendar['cal_id']}", $this->calendar['cal_title_seo'], 'cal_calendar');
//-----------------------------------------
// Try to match out and improve navigation
//-----------------------------------------
$_referrer = $_SERVER['HTTP_REFERER'];
if ($_referrer) {
//-----------------------------------------
// Came from add form?
//-----------------------------------------
if (preg_match("#/add\$#", $_referrer)) {
//.........這裏部分代碼省略.........
示例2: parseAndFetchHtmlBlocks
/**
* Parse common search results
*
* @access private
* @param array $r Search result
* @return array $html Blocks of HTML
*/
public function parseAndFetchHtmlBlocks($rows)
{
/* Forum stuff */
$sub = false;
$isVnc = false;
$search_term = IPSSearchRegistry::get('in.clean_search_term');
$results = array();
/* loop and process */
if (is_array($rows) and count($rows)) {
foreach ($rows as $id => $r) {
/* If basic search, strip the content - process only if we have content though */
if ($r['content']) {
IPSText::getTextClass('bbcode')->parse_bbcode = 0;
IPSText::getTextClass('bbcode')->strip_quotes = 1;
IPSText::getTextClass('bbcode')->parsing_section = 'topics';
IPSText::getTextClass('bbcode')->parsing_mgroup = $r['member_group_id'];
IPSText::getTextClass('bbcode')->parsing_mgroup_others = $r['mgroup_others'];
$r['content'] = strip_tags(IPSText::getTextClass('bbcode')->stripAllTags($r['content']));
$r['content'] = str_replace(array('<br>', '<br />'), '', $r['content']);
$r['content'] = trim(str_replace(array("\n\n\n", "\n\n"), "\n", str_replace("\r", '', $r['content'])));
/* Highlight */
$r['content'] = IPSText::searchHighlight($this->searchTruncate($r['content'], $search_term), $search_term);
}
/* Format title */
$r['content_title'] = IPSText::searchHighlight($r['content_title'], $search_term);
/* Format content */
list($html, $sub) = $this->formatContent($r);
$results[$id] = array('html' => $html, 'app' => $r['app'], 'type' => $r['type'], 'sub' => $sub, '_followData' => !empty($r['_followData']) ? $r['_followData'] : array());
}
}
return $results;
}
示例3: parseAndFetchHtmlBlocks
/**
* Parse search results
*
* @param array $r Search result
* @return array $html Blocks of HTML
*/
public function parseAndFetchHtmlBlocks($rows)
{
/* Forum stuff */
$sub = false;
$isVnc = false;
$search_term = IPSSearchRegistry::get('in.clean_search_term');
$noPostPreview = IPSSearchRegistry::get('opt.noPostPreview');
$results = array();
$attachPids = array();
/* loop and process */
foreach ($rows as $id => $data) {
/* Reset */
$pages = 0;
/* Set up forum */
$forum = $this->registry->getClass('class_forums')->forum_by_id[$data['forum_id']];
$this->last_topic = $data['tid'];
/* Various data */
$data['_last_post'] = $data['last_post'];
$data['_longTitle'] = $data['content_title'];
$data['_shortTitle'] = IPSText::mbstrlen(strip_tags($data['content_title'])) > 60 ? IPSText::truncate($data['content_title'], 60) : $data['content_title'];
$data['last_poster'] = $data['last_poster_id'] ? IPSMember::buildDisplayData($data['last_poster_id']) : IPSMember::buildDisplayData(IPSMember::setUpGuest($this->settings['guest_name_pre'] . $data['last_poster_name'] . $this->settings['guest_name_suf']));
$data['starter'] = $data['starter_id'] ? IPSMember::makeProfileLink($data['starter_name'], $data['starter_id'], $data['seo_first_name']) : $this->settings['guest_name_pre'] . $data['starter_name'] . $this->settings['guest_name_suf'];
//$data['last_post'] = $this->registry->getClass( 'class_localization')->getDate( $data['last_post'], 'SHORT' );
if (isset($data['post_date'])) {
$data['_post_date'] = $data['post_date'];
//$data['post_date'] = $this->registry->getClass( 'class_localization')->getDate( $data['post_date'], 'SHORT' );
}
if ($this->registry->getClass('class_forums')->canQueuePosts($forum['id'])) {
$data['posts'] += intval($data['topic_queuedposts']);
}
if ($this->registry->getClass('class_forums')->canSeeSoftDeletedPosts($forum['id'])) {
$data['posts'] += intval($data['topic_deleted_posts']);
}
if ($data['posts']) {
if (($data['posts'] + 1) % $this->settings['display_max_posts'] == 0) {
$pages = ($data['posts'] + 1) / $this->settings['display_max_posts'];
} else {
$number = ($data['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) {
$data['pages'][] = array('last' => 1, 'st' => ($pages - 1) * $this->settings['display_max_posts'], 'page' => $pages, 'total' => $pages);
break;
} else {
$data['pages'][] = array('last' => 0, 'st' => $real_no, 'page' => $page_no, 'total' => $pages);
}
}
}
/* For-matt some stuffs */
if (IPSSearchRegistry::get('opt.noPostPreview') != true) {
if (!$data['cache_content']) {
IPSText::getTextClass('bbcode')->parse_smilies = $data['use_emo'];
IPSText::getTextClass('bbcode')->parse_html = ($forum['use_html'] and $this->caches['group_cache'][$data['member_group_id']]['g_dohtml'] and $data['post_htmlstate']) ? 1 : 0;
IPSText::getTextClass('bbcode')->parse_nl2br = $data['post_htmlstate'] == 2 ? 1 : 0;
IPSText::getTextClass('bbcode')->parse_bbcode = $forum['use_ibc'];
IPSText::getTextClass('bbcode')->parsing_section = 'topics';
IPSText::getTextClass('bbcode')->parsing_mgroup = $data['member_group_id'];
IPSText::getTextClass('bbcode')->parsing_mgroup_others = $data['mgroup_others'];
$data['post'] = IPSText::getTextClass('bbcode')->preDisplayParse($data['post']);
} else {
$data['post'] = '<!--cached-' . gmdate('r', $data['cache_updated']) . '-->' . $data['cache_content'];
}
$data['post'] = IPSText::searchHighlight($data['post'], $search_term);
}
/* Has attachments */
if ($data['topic_hasattach']) {
$attachPids[$data['pid']] = $data['post'];
}
$rows[$id] = $data;
}
/* Attachments */
if (count($attachPids) and IPSSearchRegistry::get('set.returnType') != 'tids') {
/* Load attachments class */
if (!is_object($this->class_attach)) {
$classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('core') . '/sources/classes/attach/class_attach.php', 'class_attach');
$this->class_attach = new $classToLoad($this->registry);
$this->class_attach->type = 'post';
$this->class_attach->init();
}
$attachHTML = $this->class_attach->renderAttachments($attachPids, array_keys($attachPids));
/* Now parse back in the rendered posts */
if (is_array($attachHTML) and count($attachHTML)) {
foreach ($attachHTML as $id => $_data) {
/* Get rid of any lingering attachment tags */
if (stristr($_data['html'], "[attachment=")) {
$_data['html'] = IPSText::stripAttachTag($_data['html']);
}
$rows[$id]['post'] = $_data['html'];
$rows[$id]['attachmentHtml'] = $_data['attachmentHtml'];
//.........這裏部分代碼省略.........
示例4: helpShowSection
/**
* Displays a help file
*
* @return @e void
*/
public function helpShowSection()
{
/* Check ID */
$id = $this->request['HID'] ? intval($this->request['HID']) : 0;
if (!$id) {
$this->helpShowTitles();
return;
}
/* Query the hel topic */
$topic = $this->DB->buildAndFetch(array('select' => 'id, title, text', 'from' => 'faq', 'where' => 'id=' . $id));
if (!$topic['id']) {
$this->registry->output->showError('help_no_id', 10128);
}
/* Parse out board URL */
$topic['text'] = str_replace('{board_url}', $this->settings['base_url'], $topic['text']);
IPSText::getTextClass('bbcode')->parse_smilies = 1;
IPSText::getTextClass('bbcode')->parse_html = 1;
IPSText::getTextClass('bbcode')->parse_nl2br = 1;
IPSText::getTextClass('bbcode')->parse_bbcode = 1;
IPSText::getTextClass('bbcode')->parsing_section = 'global';
$topic['text'] = IPSText::getTextClass('bbcode')->preDisplayParse($topic['text']);
if ($this->request['hl']) {
$topic['text'] = IPSText::searchHighlight($topic['text'], $this->request['hl']);
$topic['title'] = IPSText::searchHighlight($topic['title'], $this->request['hl']);
}
/* Output */
$this->output .= $this->registry->output->getTemplate('help')->helpShowSection($this->lang->words['help_topic'], $this->lang->words['topic_text'], $topic['title'], $topic['text']);
/* Navigation */
$this->registry->output->setTitle($this->lang->words['help_topic'] . ': ' . $topic['title'] . ' - ' . ipsRegistry::$settings['board_name']);
$this->registry->output->addNavigation($this->lang->words['help_topics'], "app=core&module=help");
$this->registry->output->addNavigation($this->lang->words['help_topic'], '');
if ($this->request['xml'] == 1) {
$classToLoad = IPSLib::loadLibrary(IPS_KERNEL_PATH . 'classAjax.php', 'classAjax');
$classAjax = new $classToLoad();
$classAjax->returnHtml($this->output);
}
}
示例5: parsePostRow
//.........這裏部分代碼省略.........
// Parse the post
//-----------------------------------------
if (!$row['cache_content']) {
$_NOW2 = IPSDebug::getMemoryDebugFlag();
IPSText::getTextClass('bbcode')->parse_smilies = $row['use_emo'];
IPSText::getTextClass('bbcode')->parse_html = ($this->forum['use_html'] and $this->caches['group_cache'][$row['member_group_id']]['g_dohtml'] and $row['post_htmlstate']) ? 1 : 0;
IPSText::getTextClass('bbcode')->parse_nl2br = $row['post_htmlstate'] == 2 ? 1 : 0;
IPSText::getTextClass('bbcode')->parse_bbcode = $this->forum['use_ibc'];
IPSText::getTextClass('bbcode')->parsing_section = 'topics';
IPSText::getTextClass('bbcode')->parsing_mgroup = $row['member_group_id'];
IPSText::getTextClass('bbcode')->parsing_mgroup_others = $row['mgroup_others'];
/* Work around */
$_tmp = $this->memberData['view_img'];
$this->memberData['view_img'] = 1;
$row['post'] = IPSText::getTextClass('bbcode')->preDisplayParse($row['post']);
$this->memberData['view_img'] = $_tmp;
IPSDebug::setMemoryDebugFlag("topics::parsePostRow - bbcode parse - Completed", $_NOW2);
IPSContentCache::update($row['pid'], 'post', $row['post']);
/* Cache data monitor */
$this->_cacheMonitor['post']['raw']++;
} else {
$row['post'] = '<!--cached-' . gmdate('r', $row['cache_updated']) . '-->' . $row['cache_content'];
/* Cache data monitor */
$this->_cacheMonitor['post']['cached']++;
}
//-----------------------------------------
// Capture content
//-----------------------------------------
if ($this->topic['topic_firstpost'] == $row['pid']) {
$this->_firstPostContent = $row['post'];
}
//-----------------------------------------
// View image...
//-----------------------------------------
$row['post'] = IPSText::getTextClass('bbcode')->memberViewImages($row['post']);
//-----------------------------------------
// Highlight...
//-----------------------------------------
if ($this->request['hl']) {
$row['post'] = IPSText::searchHighlight($row['post'], $this->request['hl']);
}
//-----------------------------------------
// Multi Quoting?
//-----------------------------------------
if ($this->qpids) {
if (strstr(',' . $this->qpids . ',', ',' . $row['pid'] . ',')) {
$row['_mq_selected'] = 1;
}
}
//-----------------------------------------
// Multi PIDS?
//-----------------------------------------
if ($this->memberData['is_mod']) {
if ($this->request['selectedpids']) {
if (strstr(',' . $this->request['selectedpids'] . ',', ',' . $row['pid'] . ',')) {
$row['_pid_selected'] = 1;
}
$this->request['selectedpidcount'] = count(explode(",", $this->request['selectedpids']));
}
}
//-----------------------------------------
// Delete button..
//-----------------------------------------
$row['_can_delete'] = $row['pid'] != $this->topic['topic_firstpost'] ? $this->_getDeleteButtonData($row) : FALSE;
$row['_can_edit'] = $this->_getEditButtonData($row);
$row['_show_ip'] = $this->_getIPAddressData();
//-----------------------------------------
// Siggie stuff
//-----------------------------------------
$row['signature'] = "";
if (isset($poster['signature']) and $poster['signature'] and $this->memberData['view_sigs']) {
if ($row['use_sig'] == 1) {
$row['signature'] = $this->registry->output->getTemplate('global')->signature_separator($poster['signature']);
}
}
//-----------------------------------------
// Fix up the membername so it links to the members profile
//-----------------------------------------
if ($poster['member_id']) {
$poster['_members_display_name'] = "<a href='{$this->settings['_base_url']}showuser={$poster['member_id']}'>{$poster['members_display_name_short']}</a>";
}
//-----------------------------------------
// Post number
//-----------------------------------------
if ($this->topic_view_mode == 'linearplus' and $this->topic['topic_firstpost'] == $row['pid']) {
$row['post_count'] = 1;
if (!$this->first) {
$this->post_count++;
}
} else {
$this->post_count++;
$row['post_count'] = intval($this->request['st']) + $this->post_count;
}
$row['forum_id'] = $this->topic['forum_id'];
//-----------------------------------------
// Memory Debug
//-----------------------------------------
IPSDebug::setMemoryDebugFlag("PID: " . $row['pid'] . " - Completed", $_NOW);
return array('row' => $row, 'poster' => $poster);
}
示例6: calendarShowEvent
/**
* Show a single event based on eventid
*
* @access public
* @return void
*/
public function calendarShowEvent()
{
/* INIT */
$event_id = intval($this->request['event_id']);
/* Check */
if (!$event_id) {
$this->registry->output->showError('calendar_event_not_found', 10429);
}
/* Get it from the DB */
$this->DB->build(array('select' => '*', 'from' => 'cal_events', 'where' => "event_id={$event_id}"));
$this->DB->execute();
if (!($event = $this->DB->fetch())) {
$this->registry->output->showError('calendar_event_not_found', 10430);
}
$set_offset = 0;
if ($event['event_timeset']) {
$set_offset = ($this->memberData['member_id'] ? $this->memberData['time_offset'] : $this->settings['time_offset']) * 3600;
}
$event['event_unix_from'] = $event['event_unix_from'] + $set_offset;
/* Is it a private event */
if ($event['event_private'] == 1 and $this->memberData['member_id'] != $event['event_member_id']) {
$this->registry->output->showError('calendar_event_not_found', 10431);
}
/* Do we have permission to see the event? */
if ($event['event_perms'] != '*') {
$this_member_mgroups[] = $this->memberData['member_group_id'];
if ($this->memberData['mgroup_others']) {
$this_member_mgroups = array_merge($this_member_mgroups, explode(",", IPSText::cleanPermString($this->memberData['mgroup_others'])));
}
$check = 0;
foreach ($this_member_mgroups as $this_member_mgroup) {
if (preg_match("/(^|,)" . $this_member_mgroup . "(,|\$)/", $event['event_perms'])) {
$check = 1;
}
}
if ($check == 0) {
$this->registry->output->showError('calendar_event_not_found', 10432);
}
}
//-----------------------------------------
// Highlight...
//-----------------------------------------
if ($this->request['hl']) {
$event['event_content'] = IPSText::searchHighlight($event['event_content'], $this->request['hl']);
$event['event_title'] = IPSText::searchHighlight($event['event_title'], $this->request['hl']);
}
/* Output */
$this->output .= $this->registry->output->getTemplate('calendar')->calendarEventsList($this->calendarMakeEventHTML($event));
/* Navigation */
$this->registry->output->addNavigation($this->lang->words['page_title'], 'app=calendar&module=calendar');
$this->registry->output->addNavigation($this->calendar['cal_title'], 'app=calendar&module=calendar&cal_id=' . $this->calendar_id);
$this->registry->output->addNavigation($event['event_title'], '');
}
示例7: parsePostRow
/**
* Builds an array of post data for output
*
* @param array $row Array of post data
* @return array
*/
public function parsePostRow($row = array())
{
/* Init */
$topicData = $this->registry->getClass('topics')->getTopicData();
$forumData = $this->forumClass->getForumById($topicData['forum_id']);
$permissionData = $this->registry->getClass('topics')->getPermissionData();
/* Parse post */
$parsed = $this->registry->getClass('topics')->parsePost($row);
if ($parsed['post']['_can_edit']) {
$this->_canEditAPost = true;
}
/* Collect PIDS of soft deleted posts */
if ($parsed['post']['_isDeleted'] and $parsed['post']['_softDeleteSee']) {
$this->_sdPids[] = $parsed['post']['pid'];
}
/* Grab first post */
if ($topicData['topic_firstpost'] == $parsed['post']['pid']) {
$this->_firstPostContent = $parsed['post']['post'];
} else {
if ($this->request['page'] and !$this->_firstPostContent) {
$this->_firstPostContent = $parsed['post']['post'];
}
}
/* Anything to highlight? */
if (isset($this->request['hl']) and $this->request['hl']) {
$parsed['post']['post'] = IPSText::searchHighlight($parsed['post']['post'], $this->request['hl']);
}
/* Multi quote */
if ($this->qpids) {
if (strstr(',' . $this->qpids . ',', ',' . $parsed['post']['pid'] . ',')) {
$parsed['post']['_mq_selected'] = 1;
}
}
/* Mod PIDS */
if ($this->memberData['is_mod']) {
if ($this->request['selectedpids']) {
if (strstr(',' . $this->request['selectedpids'] . ',', ',' . $parsed['post']['pid'] . ',')) {
$parsed['post']['_pid_selected'] = 1;
}
$this->request['selectedpidcount'] = count(explode(",", $this->request['selectedpids']));
}
}
/* Post number */
$this->post_count++;
$parsed['post']['post_count'] = $this->request['page'] > 1 ? intval($this->request['page'] - 1) * $this->settings['display_max_posts'] + $this->post_count : $this->post_count;
if ($parsed['post']['_isDeleted']) {
$this->post_count--;
}
/* Post max date for item marking*/
if ($row['post_date'] > $this->_maxPostDate) {
$this->_maxPostDate = $row['post_date'];
}
return $parsed;
}
示例8: _topicPreview
//.........這裏部分代碼省略.........
}
/* Permission check */
if ($this->registry->class_forums->forumsCheckAccess($topic['forum_id'], 0, 'topic', $topic, true) !== true) {
return $this->returnString('no_permission');
}
/* is archived? */
$isArchived = $this->registry->topics->isArchived($topic);
/* Build permissions */
$permissions['PostSoftDeleteSee'] = $this->registry->getClass('class_forums')->canSeeSoftDeletedPosts($topic['forum_id']);
$permissions['SoftDeleteContent'] = $this->registry->getClass('class_forums')->canSeeSoftDeleteContent($topic['forum_id']);
$permissions['TopicSoftDeleteSee'] = $this->registry->getClass('class_forums')->canSeeSoftDeletedTopics($topic['forum_id']);
$permissions['canQueue'] = $this->registry->getClass('class_forums')->canQueuePosts($topic['forum_id']);
/* Boring old boringness */
if ($permissions['canQueue']) {
if ($permissions['PostSoftDeleteSee']) {
$query = $this->registry->class_forums->fetchPostHiddenQuery(array('visible', 'hidden', 'sdeleted'), $this->registry->topics->getPostTableField('_prefix_', $isArchived)) . ' AND ';
} else {
$query = $this->registry->class_forums->fetchPostHiddenQuery(array('visible', 'hidden'), $this->registry->topics->getPostTableField('_prefix_', $isArchived)) . ' AND ';
}
} else {
if ($permissions['PostSoftDeleteSee']) {
$query = $this->registry->class_forums->fetchPostHiddenQuery(array('visible', 'sdeleted'), $this->registry->topics->getPostTableField('_prefix_', $isArchived)) . ' AND ';
} else {
$query = $this->registry->class_forums->fetchPostHiddenQuery(array('visible'), $this->registry->topics->getPostTableField('_prefix_', $isArchived)) . ' AND ';
}
}
/* Get first post */
$_post = $this->registry->topics->getPosts(array('onlyViewable' => true, 'skipForumCheck' => true, 'sortField' => $this->settings['post_order_column'], 'sortOrder' => 'asc', 'topicId' => array($topic['tid']), 'limit' => 1, 'archiveToNative' => true, 'isArchivedTopic' => $this->registry->topics->isArchived($topic)));
$posts['first'] = array_pop($_post);
/* Archived? Get last post */
if ($topic['topic_posts'] && $isArchived) {
/* Get last post */
$_post = $this->registry->topics->getPosts(array('onlyViewable' => true, 'skipForumCheck' => true, 'sortField' => $this->settings['post_order_column'], 'sortOrder' => 'desc', 'topicId' => array($topic['tid']), 'limit' => 1, 'archiveToNative' => true, 'isArchivedTopic' => $this->registry->topics->isArchived($topic)));
$posts['last'] = array_pop($_post);
} else {
if ($topic['topic_posts'] && !$isArchived) {
/* Grab number of unread posts? */
$last_time = $this->registry->classItemMarking->fetchTimeLastMarked(array('forumID' => $topic['forum_id'], 'itemID' => $tid));
if ($last_time and $last_time < $topic['topic_last_post']) {
$count = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as count, MAX(' . $this->registry->topics->getPostTableField($this->settings['post_order_column'], $isArchived) . ') as max, MIN(' . $this->settings['post_order_column'] . ') as min', 'from' => $this->registry->topics->getPostTableField('_table_', $isArchived), 'where' => $query . $this->registry->topics->getPostTableField('topic_id', $isArchived) . "={$tid} AND " . $this->registry->topics->getPostTableField('post_date', $isArchived) . " > " . intval($last_time)));
} else {
$count = $this->DB->buildAndFetch(array('select' => 'MAX(' . $this->registry->topics->getPostTableField($this->settings['post_order_column'], $isArchived) . ') as max', 'from' => $this->registry->topics->getPostTableField('_table_', $isArchived), 'where' => $query . $this->registry->topics->getPostTableField('topic_id', $isArchived) . "={$tid}"));
$count['min'] = 0;
$count['count'] = 0;
}
$topic['_lastRead'] = $last_time;
$topic['_unreadPosts'] = intval($count['count']);
/* Got a max and min */
if ($count['max']) {
$_posts = $this->registry->topics->getPosts(array('onlyViewable' => true, 'postId' => $this->settings['post_order_column'] == 'pid' ? array(intval($count['min']), intval($count['max'])) : array(), 'postDate' => $this->settings['post_order_column'] == 'post_date' ? array(intval($count['min']), intval($count['max'])) : array(), 'archiveToNative' => true, 'isArchivedTopic' => $this->registry->topics->isArchived($topic)));
foreach ($_posts as $pid => $r) {
$r['tid'] = $topic['tid'];
$r['title_seo'] = $topic['title_seo'];
if ($r[$this->settings['post_order_column']] == $count['max']) {
$posts['last'] = $r;
} else {
$posts['unread'] = $r;
}
}
}
if (is_array($posts['unread']) and is_array($posts['last'])) {
if ($posts['unread']['pid'] == $posts['last']['pid']) {
unset($posts['unread']);
} else {
if ($posts['unread']['pid'] == $posts['first']['pid']) {
unset($posts['unread']);
}
}
}
}
}
/* Search? */
if ($pid and $sTerm) {
$_posts = $this->registry->topics->getPosts(array('onlyViewable' => true, 'postId' => array($pid), 'archiveToNative' => true, 'isArchivedTopic' => $this->registry->topics->isArchived($topic)));
$posts['search'] = array_pop($_posts);
}
$classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/text/parser.php', 'classes_text_parser');
$parser = new $classToLoad();
/* Set up some settings */
$parser->set(array('parseArea' => 'topics', 'memberData' => $this->memberData, 'parseBBCode' => $this->registry->class_forums->forum_by_id[$topic['forum_id']]['use_ibc'], 'parseHtml' => ($this->registry->class_forums->forum_by_id[$topic['forum_id']]['use_html'] and $this->caches['group_cache'][$data['member_group_id']]['g_dohtml'] and $data['post_htmlstate']) ? 1 : 0, 'parseEmoticons' => $data['use_emo']));
/* Still here? */
foreach ($posts as $k => $data) {
$data = IPSMember::buildDisplayData($data);
$data['post'] = $parser->stripQuotes($data['post']);
$data['post'] = $parser->display($data['post']);
/* Search term? */
if ($k == 'search' and $pid and $sTerm) {
$data['post'] = IPSText::truncateTextAroundPhrase(IPSText::getTextClass('bbcode')->stripAllTags(str_replace('<br />', ' ', strip_tags($data['post'], '<br>'))), $sTerm);
$data['post'] = IPSText::searchHighlight($data['post'], $sTerm);
} else {
$data['post'] = IPSText::truncate(IPSText::getTextClass('bbcode')->stripAllTags(strip_tags($data['post'], '<br>')), 500);
}
$data['_isVisible'] = $this->registry->getClass('class_forums')->fetchHiddenType($data) == 'visible' ? true : false;
$data['_isHidden'] = $this->registry->getClass('class_forums')->fetchHiddenType($data) == 'hidden' ? true : false;
$data['_isDeleted'] = $this->registry->getClass('class_forums')->fetchHiddenType($data) == 'sdelete' ? true : false;
$posts[$k] = $data;
}
$topic['_key'] = uniqid(microtime());
return $this->returnHtml($this->registry->output->getTemplate('topic')->topicPreview($topic, $posts));
}
示例9: _parseSearchResult
/**
* Parse a common search result
*
* @access private
* @param array $r Search result
* @param string $search_term Keywords searched for
* @param bool $isVnc Is from view new content
* @return array $search_result Search result for template
*/
private function _parseSearchResult($r, $search_term = '', $isVnc = false)
{
/* Forum stuff */
$sub = false;
$r['_topic_array'] = $this->_topicArray;
/* If basic search, strip the content */
IPSText::getTextClass('bbcode')->parse_wordwrap = 0;
IPSText::getTextClass('bbcode')->parse_bbcode = 0;
IPSText::getTextClass('bbcode')->strip_quotes = 1;
IPSText::getTextClass('bbcode')->parsing_section = 'topics';
IPSText::getTextClass('bbcode')->parsing_mgroup = $r['member_group_id'];
IPSText::getTextClass('bbcode')->parsing_mgroup_others = $r['mgroup_others'];
$r['content'] = strip_tags(IPSText::getTextClass('bbcode')->stripAllTags($r['content']));
$r['content'] = str_replace(array('<br>', '<br />'), '', $r['content']);
$r['content'] = trim(str_replace(array("\n\n\n", "\n\n"), "\n", str_replace("\r", '', $r['content'])));
/* Highlight */
$r['content'] = IPSText::searchHighlight($this->_searchTruncate($r['content'], $search_term), $search_term);
$r['content_title'] = (!$this->search_plugin->onlyPosts and $this->_getShowAsForum() === false) ? IPSText::searchHighlight($r['content_title'], $search_term) : $r['content_title'];
/* Check to see if the display plugin is loaded */
if (!isset($this->search_plugin->display_plugins[$r['app']])) {
$this->search_plugin->display_plugins[$r['app']] = IPSSearchIndex::getSearchDisplayPlugin($r['app']);
$this->search_plugin->display_plugins[$r['app']]->search_plugin = $this->search_plugin;
}
/* Return the formatted result */
if (isset($this->search_plugin->display_plugins[$r['app']]) && is_object($this->search_plugin->display_plugins[$r['app']])) {
$return = $this->search_plugin->display_plugins[$r['app']]->formatContent($r, $isVnc);
if (is_array($return)) {
$html = $return[0];
$sub = $return[1];
} else {
$html = $return;
}
} else {
$html = $this->registry->output->getTemplate('search')->searchRowGenericFormat($r);
}
return array('html' => $html, 'app' => $r['app'], 'type' => $r['type'], 'sub' => $sub);
}