本文整理匯總了PHP中IPSText::truncateTextAroundPhrase方法的典型用法代碼示例。如果您正苦於以下問題:PHP IPSText::truncateTextAroundPhrase方法的具體用法?PHP IPSText::truncateTextAroundPhrase怎麽用?PHP IPSText::truncateTextAroundPhrase使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類IPSText
的用法示例。
在下文中一共展示了IPSText::truncateTextAroundPhrase方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: _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));
}