本文整理汇总了PHP中KunenaForumMessageHelper::getLatestMessages方法的典型用法代码示例。如果您正苦于以下问题:PHP KunenaForumMessageHelper::getLatestMessages方法的具体用法?PHP KunenaForumMessageHelper::getLatestMessages怎么用?PHP KunenaForumMessageHelper::getLatestMessages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KunenaForumMessageHelper
的用法示例。
在下文中一共展示了KunenaForumMessageHelper::getLatestMessages方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPosts
/**
* @param UserTable $viewer Viewing User
* @param UserTable $user Viewed at User
* @param TabTable $tab Current Tab
* @param PluginTable $plugin Current Plugin
* @return string HTML
*/
public static function getPosts($viewer, $user, $tab, $plugin)
{
global $_CB_framework, $_CB_database;
if (!class_exists('KunenaForumMessageHelper')) {
return CBTxt::T('Kunena not installed, enabled, or failed to load.');
}
$exclude = $plugin->params->get('forum_exclude', null);
if ($exclude) {
$exclude = explode('|*|', $exclude);
cbArrayToInts($exclude);
$exclude = implode(',', $exclude);
}
cbimport('cb.pagination');
cbforumsClass::getTemplate('tab_posts');
$limit = (int) $tab->params->get('tab_posts_limit', 15);
$limitstart = $_CB_framework->getUserStateFromRequest('tab_posts_limitstart{com_comprofiler}', 'tab_posts_limitstart');
$filterSearch = $_CB_framework->getUserStateFromRequest('tab_posts_search{com_comprofiler}', 'tab_posts_search');
$where = array();
if (isset($filterSearch) && $filterSearch != '') {
$where[] = '( m.' . $_CB_database->NameQuote('subject') . ' LIKE ' . $_CB_database->Quote('%' . $_CB_database->getEscaped($filterSearch, true) . '%', false) . ' OR t.' . $_CB_database->NameQuote('message') . ' LIKE ' . $_CB_database->Quote('%' . $_CB_database->getEscaped($filterSearch, true) . '%', false) . ' )';
}
$searching = count($where) ? true : false;
if ($exclude) {
$where[] = '( m.' . $_CB_database->NameQuote('catid') . ' NOT IN ( ' . $exclude . ' ) )';
}
$params = array('user' => (int) $user->id, 'starttime' => -1, 'where' => count($where) ? implode(' AND ', $where) : null);
$posts = KunenaForumMessageHelper::getLatestMessages(false, 0, 0, $params);
$total = array_shift($posts);
if ($total <= $limitstart) {
$limitstart = 0;
}
$pageNav = new cbPageNav($total, $limitstart, $limit);
$pageNav->setInputNamePrefix('tab_posts_');
if ($tab->params->get('tab_posts_paging', 1)) {
$posts = KunenaForumMessageHelper::getLatestMessages(false, (int) $pageNav->limitstart, (int) $pageNav->limit, $params);
$posts = array_pop($posts);
} else {
$posts = array_pop($posts);
}
$rows = array();
/** @var KunenaForumMessage[] $posts */
if ($posts) {
foreach ($posts as $post) {
$row = new stdClass();
$row->id = $post->id;
$row->subject = $post->subject;
$row->message = $post->message;
$row->date = $post->time;
$row->url = $post->getUrl();
$row->category_id = $post->getCategory()->id;
$row->category_name = $post->getCategory()->name;
$row->category_url = $post->getCategory()->getUrl();
$rows[] = $row;
}
}
$input = array();
$input['search'] = '<input type="text" name="tab_posts_search" value="' . htmlspecialchars($filterSearch) . '" onchange="document.forumPostsForm.submit();" placeholder="' . htmlspecialchars(CBTxt::T('Search Posts...')) . '" class="form-control" />';
return HTML_cbforumsTabPosts::showPosts($rows, $pageNav, $searching, $input, $viewer, $user, $tab, $plugin);
}
示例2: getMessagesItems
/**
* Method to get all deleted messages.
*
* @return Array
* @since 1.6
*/
public function getMessagesItems() {
$cats = KunenaForumCategoryHelper::getCategories();
$cats_array =array();
foreach ($cats as $cat) {
if ( $cat->id ) $cats_array[] = $cat->id;
}
list($total,$messages) = KunenaForumMessageHelper::getLatestMessages($cats_array, $this->getState('list.start'), $this->getState('list.limit'), array ('hold' => '2,3'));
$this->setState ( 'list.total', $total );
return $messages;
}
示例3: getForum
static public function getForum( $tabs, $row, $user, $plugin ) {
global $_CB_database;
if ( ! class_exists( 'KunenaForumMessageHelper' ) ) {
return CBTxt::T( 'Kunena not installed, enabled, or failed to load.' );
}
$params = $row->getParams();
$forumId = $params->get( 'forum_id', null );
cbgjClass::getTemplate( 'cbgroupjiveforums' );
$paging = new cbgjPaging( 'forum' );
$limit = $paging->getlimit( (int) $plugin->params->get( 'forum_limit', 15 ) );
$limitstart = $paging->getLimistart();
$search = $paging->getFilter( 'search' );
$where = array();
if ( isset( $search ) && ( $search != '' ) ) {
$where[] = '( m.' . $_CB_database->NameQuote( 'subject' ) . ' LIKE ' . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $search, true ) . '%', false )
. ' OR t.' . $_CB_database->NameQuote( 'message' ) . ' LIKE ' . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $search, true ) . '%', false ) . ' )';
}
$params = array( 'starttime' => -1,
'where' => ( count( $where ) ? implode( ' AND ', $where ) : null )
);
$rows = KunenaForumMessageHelper::getLatestMessages( $forumId, 0, 0, $params );
$total = array_shift( $rows );
if ( $total <= $limitstart ) {
$limitstart = 0;
}
$pageNav = $paging->getPageNav( $total, $limitstart, $limit );
if ( $plugin->params->get( 'forum_paging', 1 ) ) {
$rows = KunenaForumMessageHelper::getLatestMessages( $forumId, (int) $pageNav->limitstart, (int) $pageNav->limit, $params );
$rows = array_pop( $rows );
} else {
$rows = array_pop( $rows );
}
$pageNav->search = $paging->getInputSearch( 'gjForm_forum', 'search', CBTxt::T( 'Search Forums...' ), $search );
$pageNav->searching = ( $search ? true : false );
$pageNav->limitbox = $paging->getLimitbox( $pageNav );
$pageNav->pagelinks = $paging->getPagesLinks( $pageNav );
if ( class_exists( 'HTML_cbgroupjiveforums' ) ) {
return HTML_cbgroupjiveforums::showForums( $rows, $pageNav, $tabs, $row, $user, $plugin );
} else {
return cbgjForumsPlugin::showForum( $rows, $pageNav, $tabs, $row, $user, $plugin );
}
}
示例4: getPosts
protected function getPosts() {
$this->topics = array();
$start = $this->getState ( 'list.start' );
$limit = $this->getState ( 'list.limit' );
$params = array();
$params['mode'] = $this->getState ( 'list.mode' );
$params['reverse'] = ! $this->getState ( 'list.categories.in' );
$params['starttime'] = $this->getState ( 'list.time' );
$params['user'] = $this->getState ( 'user' );
list ($this->total, $this->messages) = KunenaForumMessageHelper::getLatestMessages($this->getState ( 'list.categories' ), $start, $limit, $params);
$topicids = array();
foreach ( $this->messages as $message ) {
$topicids[$message->thread] = $message->thread;
}
$authorise = 'read';
switch ($params['mode']) {
case 'unapproved':
$authorise = 'approve';
break;
case 'deleted':
$authorise = 'undelete';
break;
}
$this->topics = KunenaForumTopicHelper::getTopics ( $topicids, $authorise );
$this->_common();
}
示例5: ban
//.........这里部分代码省略.........
$ip = JRequest::getString('ip', '');
$block = JRequest::getInt('block', 0);
$expiration = JRequest::getString('expiration', '');
$reason_private = JRequest::getString('reason_private', '');
$reason_public = JRequest::getString('reason_public', '');
$comment = JRequest::getString('comment', '');
if (!$ban->id) {
$ban->ban($user->userid, $ip, $block, $expiration, $reason_private, $reason_public, $comment);
$success = $ban->save();
$this->report($user->userid);
} else {
$delban = JRequest::getString('delban', '');
if ($delban) {
$ban->unBan($comment);
$success = $ban->save();
} else {
$ban->blocked = $block;
$ban->setExpiration($expiration, $comment);
$ban->setReason($reason_public, $reason_private);
$success = $ban->save();
}
}
if ($block) {
if ($ban->isEnabled()) {
$message = JText::_('COM_KUNENA_USER_BLOCKED_DONE');
} else {
$message = JText::_('COM_KUNENA_USER_UNBLOCKED_DONE');
}
} else {
if ($ban->isEnabled()) {
$message = JText::_('COM_KUNENA_USER_BANNED_DONE');
} else {
$message = JText::_('COM_KUNENA_USER_UNBANNED_DONE');
}
}
if (!$success) {
$this->app->enqueueMessage($ban->getError(), 'error');
} else {
$this->app->enqueueMessage($message);
}
$banDelPosts = JRequest::getString('bandelposts', '');
$DelAvatar = JRequest::getString('delavatar', '');
$DelSignature = JRequest::getString('delsignature', '');
$DelProfileInfo = JRequest::getString('delprofileinfo', '');
if (!empty($DelAvatar) || !empty($DelProfileInfo)) {
jimport('joomla.filesystem.file');
$avatar_deleted = '';
// Delete avatar from file system
if (JFile::exists(JPATH_ROOT . '/media/kunena/avatars/' . $user->avatar) && !stristr($user->avatar, 'gallery/')) {
JFile::delete(JPATH_ROOT . '/media/kunena/avatars/' . $user->avatar);
$avatar_deleted = JText::_('COM_KUNENA_MODERATE_DELETED_BAD_AVATAR_FILESYSTEM');
}
$user->avatar = '';
$user->save();
$this->app->enqueueMessage(JText::_('COM_KUNENA_MODERATE_DELETED_BAD_AVATAR') . $avatar_deleted);
}
if (!empty($DelProfileInfo)) {
$user->personalText = '';
$user->birthdate = '0000-00-00';
$user->location = '';
$user->gender = 0;
$user->icq = '';
$user->aim = '';
$user->yim = '';
$user->msn = '';
$user->skype = '';
$user->gtalk = '';
$user->twitter = '';
$user->facebook = '';
$user->myspace = '';
$user->linkedin = '';
$user->delicious = '';
$user->friendfeed = '';
$user->digg = '';
$user->blogspot = '';
$user->flickr = '';
$user->bebo = '';
$user->websitename = '';
$user->websiteurl = '';
$user->signature = '';
$user->save();
$this->app->enqueueMessage(JText::_('COM_KUNENA_MODERATE_DELETED_BAD_PROFILEINFO'));
} elseif (!empty($DelSignature)) {
$user->signature = '';
$user->save();
$this->app->enqueueMessage(JText::_('COM_KUNENA_MODERATE_DELETED_BAD_SIGNATURE'));
}
if (!empty($banDelPosts)) {
$params = array('starttime' => '-1', 'user' => $user->userid, 'mode' => 'unapproved');
list($total, $messages) = KunenaForumMessageHelper::getLatestMessages(false, 0, 0, $params);
$parmas_recent = array('starttime' => '-1', 'user' => $user->userid);
list($total, $messages_recent) = KunenaForumMessageHelper::getLatestMessages(false, 0, 0, $parmas_recent);
$messages = array_merge($messages_recent, $messages);
foreach ($messages as $mes) {
$mes->publish(KunenaForum::DELETED);
}
$this->app->enqueueMessage(JText::_('COM_KUNENA_MODERATE_DELETED_BAD_MESSAGES'));
}
$this->app->redirect($user->getUrl(false));
}
示例6: getResults
public function getResults()
{
if ($this->messages !== false) {
return $this->messages;
}
$q = $this->getState('searchwords');
if (!$q && !$this->getState('query.searchuser')) {
$this->setError(JText::_('COM_KUNENA_SEARCH_ERR_SHORTKEYWORD'));
return array();
}
/* get results */
$hold = $this->getState('query.show');
if ($hold == 1) {
$mode = 'unapproved';
} elseif ($hold >= 2) {
$mode = 'deleted';
} else {
$mode = 'recent';
}
$params = array('mode' => $mode, 'childforums' => $this->getState('query.childforums'), 'where' => $this->buildWhere(), 'orderby' => $this->buildOrderBy(), 'starttime' => -1);
$limitstart = $this->getState('list.start');
$limit = $this->getState('list.limit');
list($this->total, $this->messages) = KunenaForumMessageHelper::getLatestMessages($this->getState('query.catids'), $limitstart, $limit, $params);
if ($this->total < $limitstart) {
$this->setState('list.start', intval($this->total / $limit) * $limit);
}
$topicids = array();
$userids = array();
foreach ($this->messages as $message) {
$topicids[$message->thread] = $message->thread;
$userids[$message->userid] = $message->userid;
}
if ($topicids) {
$topics = KunenaForumTopicHelper::getTopics($topicids);
foreach ($topics as $topic) {
$userids[$topic->first_post_userid] = $topic->first_post_userid;
}
}
KunenaUserHelper::loadUsers($userids);
KunenaForumMessageHelper::loadLocation($this->messages);
if (empty($this->messages)) {
$this->app->enqueueMessage(JText::sprintf('COM_KUNENA_SEARCH_NORESULTS_FOUND', $q));
}
return $this->messages;
}
示例7: movemessages
function movemessages()
{
if (!JSession::checkToken('post')) {
$this->app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error');
$this->app->redirect(KunenaRoute::_($this->baseurl, false));
}
$catid = JRequest::getInt('catid');
$uids = (array) $this->app->getUserState('kunena.usermove.userids');
$error = null;
if ($uids) {
foreach ($uids as $id) {
list($total, $messages) = KunenaForumMessageHelper::getLatestMessages(false, 0, 0, array('starttime' => '-1', 'user' => $id));
foreach ($messages as $object) {
$topic = $object->getTopic();
if (!$object->authorise('move')) {
$error = $object->getError();
} else {
$target = KunenaForumCategoryHelper::get($catid);
if (!$topic->move($target, false, false, '', false)) {
$error = $topic->getError();
}
}
}
}
} else {
$this->app->enqueueMessage(JText::_('COM_KUNENA_PROFILE_NO_USER'), 'error');
$this->app->redirect(KunenaRoute::_($this->baseurl, false));
}
if ($error) {
$this->app->enqueueMessage($error, 'notice');
} else {
$this->app->enqueueMessage(JText::_('COM_KUNENA_A_USERMES_MOVED_DONE'));
}
$this->app->redirect(KunenaRoute::_($this->baseurl, false));
}
示例8: getTopics
/**
* @param UserTable $user
* @param GroupTable $group
* @param array $counters
* @return array|null
*/
public function getTopics( $user, &$group, &$counters )
{
global $_CB_framework, $_CB_database;
$categoryId = (int) $group->params()->get( 'forum_id' );
if ( ( ! $categoryId ) || ( ! $group->params()->get( 'forums', 1 ) ) || ( $group->category()->get( 'id' ) && ( ! $group->category()->params()->get( 'forums', 1 ) ) ) ) {
return null;
}
CBGroupJive::getTemplate( 'forums', true, true, $this->plugin->element );
$limit = (int) $this->params->get( 'groups_forums_limit', 15 );
$limitstart = $_CB_framework->getUserStateFromRequest( 'gj_group_forums_limitstart{com_comprofiler}', 'gj_group_forums_limitstart' );
$search = $_CB_framework->getUserStateFromRequest( 'gj_group_forums_search{com_comprofiler}', 'gj_group_forums_search' );
$where = null;
if ( $search && $this->params->get( 'groups_forums_search', 1 ) ) {
$where .= '( m.' . $_CB_database->NameQuote( 'subject' ) . ' LIKE ' . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $search, true ) . '%', false )
. ' OR t.' . $_CB_database->NameQuote( 'message' ) . ' LIKE ' . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $search, true ) . '%', false ) . ' )';
}
$searching = ( $where ? true : false );
$params = array( 'starttime' => -1,
'where' => $where
);
$posts = \KunenaForumMessageHelper::getLatestMessages( $categoryId, 0, 0, $params );
$total = array_shift( $posts );
if ( ( ! $total ) && ( ! $searching ) && ( ! CBGroupJive::canCreateGroupContent( $user, $group, 'forums' ) ) ) {
return null;
}
$pageNav = new \cbPageNav( $total, $limitstart, $limit );
$pageNav->setInputNamePrefix( 'gj_group_forums_' );
switch( (int) $this->params->get( 'groups_forums_orderby', 2 ) ) {
case 1:
$params['orderby'] = 'm.' . $_CB_database->NameQuote( 'time' ) . ' ASC';
break;
}
if ( $this->params->get( 'groups_forums_paging', 1 ) ) {
$posts = \KunenaForumMessageHelper::getLatestMessages( $categoryId, (int) $pageNav->limitstart, (int) $pageNav->limit, $params );
$posts = array_pop( $posts );
} else {
$posts = array_pop( $posts );
}
$rows = array();
/** @var \KunenaForumMessage[] $posts */
foreach ( $posts as $post ) {
$row = new PostTable();
$row->post( $post );
$rows[] = $row;
}
$input = array();
$input['search'] = '<input type="text" name="gj_group_forums_search" value="' . htmlspecialchars( $search ) . '" onchange="document.gjGroupForumsForm.submit();" placeholder="' . htmlspecialchars( CBTxt::T( 'Search Posts...' ) ) . '" class="form-control" />';
CBGroupJive::preFetchUsers( $rows );
$group->set( '_forums', $pageNav->total );
return array( 'id' => 'forums',
'title' => CBTxt::T( 'Forums' ),
'content' => \HTML_groupjiveForums::showForums( $rows, $pageNav, $searching, $input, $counters, $group, $user, $this )
);
}
示例9: getUserPosts
/**
* Puts users posts into array
*
* @param moscomprofilerUser $user
* @param object $forum
* @return object
*/
function getUserPosts($user, $forum)
{
global $_CB_framework, $_CB_database;
$categories = $this->getAllowedCategories(null, $forum);
$pagingParams = $this->_getPaging(array(), array('fposts_'));
$postsNumber = $this->params->get('postsNumber', 10);
if ($forum->prefix != 'kunena' || $forum->prefix == 'kunena' && !class_exists('KunenaForum')) {
switch ($pagingParams['fposts_sortby']) {
case 'subjectASC':
$order = 'a.' . $_CB_database->NameQuote('subject') . ' ASC';
break;
case 'subjectDESC':
$order = 'a.' . $_CB_database->NameQuote('subject') . ' DESC';
break;
case 'categoryASC':
$order = 'b.' . $_CB_database->NameQuote('id') . ' ASC';
break;
case 'categoryDESC':
$order = 'b.' . $_CB_database->NameQuote('id') . ' DESC';
break;
case 'hitsASC':
$order = 'c.' . $_CB_database->NameQuote('hits') . ' ASC';
break;
case 'hitsDESC':
$order = 'c.' . $_CB_database->NameQuote('hits') . ' DESC';
break;
case 'dateASC':
$order = 'a.' . $_CB_database->NameQuote('time') . ' ASC';
break;
case 'dateDESC':
default:
$order = 'a.' . $_CB_database->NameQuote('time') . ' DESC';
break;
}
if (strcasecmp(substr($forum->version, 0, 3), '1.7') >= 0) {
$cbUser =& CBuser::getInstance((int) $user->id);
if (!$cbUser) {
$cbUser =& CBuser::getInstance(null);
}
$access = "\n AND ( ( b." . $_CB_database->NameQuote('access') . " IN ( " . implode(',', $cbUser->getAuthorisedViewLevelsIds(false)) . " )" . ' AND b.' . $_CB_database->NameQuote('accesstype') . ' = ' . $_CB_database->Quote('joomla.level') . ' )' . "\n OR ( b." . $_CB_database->NameQuote('pub_access') . " IN ( " . implode(',', $_CB_framework->acl->get_groups_below_me((int) $user->id, true)) . " )" . ' AND b.' . $_CB_database->NameQuote('accesstype') . ' = ' . $_CB_database->Quote('none') . ' )';
} else {
$access = "\n AND ( b." . $_CB_database->NameQuote('pub_access') . " IN ( " . implode(',', $_CB_framework->acl->get_groups_below_me((int) $user->id, true)) . " )";
}
$access .= $categories ? "\n OR b." . $_CB_database->NameQuote('id') . " IN ( " . implode(',', $categories) . " ) )" : ' )';
$query = 'SELECT a.*' . ', b.' . $_CB_database->NameQuote('id') . ' AS category' . ', b.' . $_CB_database->NameQuote('name') . ' AS catname' . ', c.' . $_CB_database->NameQuote('hits') . ' AS threadhits' . "\n FROM " . $_CB_database->NameQuote('#__' . $forum->prefix . '_messages') . " AS a" . "\n LEFT JOIN " . $_CB_database->NameQuote('#__' . $forum->prefix . '_categories') . " AS b" . ' ON a.' . $_CB_database->NameQuote('catid') . ' = b.' . $_CB_database->NameQuote('id') . "\n LEFT JOIN " . $_CB_database->NameQuote('#__' . $forum->prefix . '_messages') . " AS c" . ' ON a.' . $_CB_database->NameQuote('thread') . ' = c.' . $_CB_database->NameQuote('id') . "\n LEFT JOIN " . $_CB_database->NameQuote('#__' . $forum->prefix . '_messages_text') . " AS d" . ' ON a.' . $_CB_database->NameQuote('id') . ' = d.' . $_CB_database->NameQuote('mesid') . "\n WHERE a." . $_CB_database->NameQuote('hold') . " = 0" . "\n AND b." . $_CB_database->NameQuote('published') . " = 1" . "\n AND a." . $_CB_database->NameQuote('userid') . " = " . (int) $user->id . $access . ($pagingParams['fposts_search'] ? "\n AND ( a." . $_CB_database->NameQuote('subject') . " LIKE '%" . cbEscapeSQLsearch(cbGetEscaped($pagingParams['fposts_search'])) . "%' OR d." . $_CB_database->NameQuote('message') . " LIKE '%" . cbEscapeSQLsearch($pagingParams['fposts_search']) . "%' )" : null) . "\n ORDER BY " . $order;
$_CB_database->setQuery($query, (int) ($pagingParams['fposts_limitstart'] ? $pagingParams['fposts_limitstart'] : 0), (int) $postsNumber);
$posts = $_CB_database->loadObjectList();
} elseif (class_exists('KunenaForumMessageHelper')) {
$where = array();
if (isset($pagingParams['fposts_search']) && $pagingParams['fposts_search'] != '') {
$where[] = '( m.' . $_CB_database->NameQuote('subject') . ' LIKE ' . $_CB_database->Quote('%' . $_CB_database->getEscaped($pagingParams['fposts_search'], true) . '%', false) . ' OR t.' . $_CB_database->NameQuote('message') . ' LIKE ' . $_CB_database->Quote('%' . $_CB_database->getEscaped($pagingParams['fposts_search'], true) . '%', false) . ' )';
}
switch ($pagingParams['fposts_sortby']) {
case 'subjectASC':
$order = 'm.' . $_CB_database->NameQuote('subject') . ' ASC';
break;
case 'subjectDESC':
$order = 'm.' . $_CB_database->NameQuote('subject') . ' DESC';
break;
case 'categoryASC':
$order = 'm.' . $_CB_database->NameQuote('catid') . ' ASC';
break;
case 'categoryDESC':
$order = 'm.' . $_CB_database->NameQuote('catid') . ' DESC';
break;
case 'hitsASC':
$order = 'm.' . $_CB_database->NameQuote('hits') . ' ASC';
break;
case 'hitsDESC':
$order = 'm.' . $_CB_database->NameQuote('hits') . ' DESC';
break;
case 'dateASC':
$order = 'm.' . $_CB_database->NameQuote('time') . ' ASC';
break;
case 'dateDESC':
default:
$order = 'm.' . $_CB_database->NameQuote('time') . ' DESC';
break;
}
$params = array('user' => (int) $user->id, 'starttime' => -1, 'where' => count($where) ? implode(' AND ', $where) : null, 'orderby' => $order);
$posts = array_pop(KunenaForumMessageHelper::getLatestMessages(false, (int) ($pagingParams['fposts_limitstart'] ? $pagingParams['fposts_limitstart'] : 0), (int) $postsNumber, $params));
if ($posts) {
foreach ($posts as $k => $post) {
$posts[$k]->set('category', $post->getCategory()->id);
$posts[$k]->set('catname', $post->getCategory()->name);
$posts[$k]->set('threadhits', $post->getTopic()->hits);
}
}
} else {
$posts = null;
}
return $posts;
}
示例10: plgSearchKunena
/**
* @param $text
* @param string $phrase
* @param string $ordering
* @param null $areas
*
* @return array
*/
function plgSearchKunena($text, $phrase = '', $ordering = '', $areas = null)
{
//If the array is not correct, return it:
if (is_array($areas) && !array_intersect($areas, array_keys(plgSearchKunenaAreas()))) {
return array();
}
$plugin = JPluginHelper::getPlugin('search', 'kunena');
$pluginParams = new JRegistry();
$pluginParams->loadString($plugin->params);
//And define the parameters. For example like this..
$limit = $pluginParams->get('search_limit', 50);
$contentLimit = $pluginParams->get('content_limit', 40);
$bbcode = $pluginParams->get('show_bbcode', 1);
$openInNewPage = $pluginParams->get('open_new_page', 1);
//Use the function trim to delete spaces in front of or at the back of the searching terms
$text = trim($text);
//Return Array when nothing was filled in
if ($text == '') {
return array();
}
$db = JFactory::getDbo();
//After this, you have to add the database part. This will be the most difficult part, because this changes per situation.
//In the coding examples later on you will find some of the examples used by Joomla! 1.5 core Search Plugins.
//It will look something like this.
switch ($phrase) {
//search exact
case 'exact':
$text = $db->quote('%' . $db->escape($text) . '%', false);
$where = "(m.subject LIKE {$text} OR t.message LIKE {$text})";
break;
//search all or any
//search all or any
case 'all':
case 'any':
default:
$where = array();
$words = explode(' ', $text);
foreach ($words as $word) {
$word = $db->quote('%' . $db->escape(trim($word)) . '%', false);
$where[] = "m.subject LIKE {$word} OR t.message LIKE {$word}";
}
$where = '(' . implode($phrase == 'all' ? ') AND (' : ') OR (', $where) . ')';
break;
}
//ordering of the results
switch ($ordering) {
//oldest first
case 'oldest':
$orderby = 'm.time ASC';
break;
//popular first
//popular first
case 'popular':
// FIXME: should be topic hits
$orderby = 'm.hits DESC, m.time DESC';
break;
//newest first
//newest first
case 'newest':
$orderby = 'm.time DESC';
break;
//alphabetic, ascending
//alphabetic, ascending
case 'alpha':
//default setting: alphabetic, ascending
//default setting: alphabetic, ascending
default:
$orderby = 'm.subject ASC, m.time DESC';
}
$params = array('orderby' => $orderby, 'where' => $where, 'starttime' => -1);
list($total, $messages) = KunenaForumMessageHelper::getLatestMessages(false, 0, $limit, $params);
$rows = array();
foreach ($messages as $message) {
/** @var KunenaForumMessage $message */
// Function must return: href, title, section, created, text, browsernav
$row = new StdClass();
$row->id = $message->id;
$row->href = $message->getUrl();
$row->title = JString::substr($message->subject, '0', $contentLimit);
$row->section = $message->getCategory()->name;
$row->created = $message->time;
if ($bbcode) {
$row->text = KunenaHtmlParser::parseBBCode($message->message, $contentLimit);
} else {
$row->text = KunenaHtmlParser::stripBBCode($message->message, $contentLimit);
}
$row->browsernav = $openInNewPage ? 1 : 0;
$rows[] = $row;
}
//Return the search results in an array
return $rows;
}
示例11: _getMessagesItems
/**
* Method to get all deleted messages.
*
* @return Array
* @since 1.6
*/
protected function _getMessagesItems()
{
$db = JFactory::getDBO();
$where = '';
if ($this->getState('list.search')) {
$where = '( m.subject LIKE ' . $db->Quote('%' . $db->getEscaped($this->getState('list.search'), true) . '%', false) . ' OR m.name LIKE ' . $db->Quote('%' . $db->getEscaped($this->getState('list.search'), true) . '%', false) . ' OR m.id LIKE ' . $db->Quote('%' . $db->getEscaped($this->getState('list.search'), true) . '%', false) . ' )';
}
$orderby = '';
$ordering = $this->state->get('list.ordering');
if (!empty($ordering)) {
$orderby = $this->state->get('list.ordering') . ' ' . $this->state->get('list.direction');
} else {
$orderby = 'm.id ' . $this->state->get('list.direction');
}
$params = array('starttime' => '-1', 'orderby' => $orderby, 'mode' => 'deleted', 'where' => $where);
$cats = KunenaForumCategoryHelper::getCategories();
$cats_array = array();
foreach ($cats as $cat) {
if ($cat->id) {
$cats_array[] = $cat->id;
}
}
list($total, $messages) = KunenaForumMessageHelper::getLatestMessages($cats_array, $this->getState('list.start'), $this->getState('list.limit'), $params);
$this->setState('list.total', $total);
return $messages;
}