本文整理汇总了PHP中KunenaForumCategoryHelper类的典型用法代码示例。如果您正苦于以下问题:PHP KunenaForumCategoryHelper类的具体用法?PHP KunenaForumCategoryHelper怎么用?PHP KunenaForumCategoryHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KunenaForumCategoryHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCatsubcriptions
public function getCatsubcriptions()
{
$db = JFactory::getDBO();
$userid = $this->getState($this->getName() . '.id');
$subscatslist = KunenaForumCategoryHelper::getSubscriptions($userid);
return $subscatslist;
}
示例2: recount
function recount() {
$app = JFactory::getApplication ();
$state = $app->getUserState ( 'com_kunena.admin.recount', null );
if ($state === null) {
// First run
$query = "SELECT MAX(id) FROM #__kunena_messages";
$db = JFactory::getDBO();
$db->setQuery ( $query );
$state = new StdClass();
$state->step = 0;
$state->maxId = (int) $db->loadResult ();
$state->start = 0;
}
$this->checkTimeout();
while (1) {
$count = mt_rand(95000, 105000);
switch ($state->step) {
case 0:
// Update topic statistics
kimport('kunena.forum.topic.helper');
KunenaForumTopicHelper::recount(false, $state->start, $state->start+$count);
$state->start += $count;
//$app->enqueueMessage ( JText::sprintf('COM_KUNENA_ADMIN_RECOUNT_TOPICS', min($state->start, $state->maxId), $state->maxId) );
break;
case 1:
// Update usertopic statistics
kimport('kunena.forum.topic.user.helper');
KunenaForumTopicUserHelper::recount(false, $state->start, $state->start+$count);
$state->start += $count;
//$app->enqueueMessage ( JText::sprintf('COM_KUNENA_ADMIN_RECOUNT_USERTOPICS', min($state->start, $state->maxId), $state->maxId) );
break;
case 2:
// Update user statistics
kimport('kunena.user.helper');
KunenaUserHelper::recount();
//$app->enqueueMessage ( JText::sprintf('COM_KUNENA_ADMIN_RECOUNT_USER') );
break;
case 3:
// Update category statistics
kimport('kunena.forum.category.helper');
KunenaForumCategoryHelper::recount();
//$app->enqueueMessage ( JText::sprintf('COM_KUNENA_ADMIN_RECOUNT_CATEGORY') );
break;
default:
$app->setUserState ( 'com_kunena.admin.recount', null );
$app->enqueueMessage (JText::_('COM_KUNENA_RECOUNTFORUMS_DONE'));
$this->setRedirect(KunenaRoute::_('index.php?option=com_kunena', false));
return;
}
if (!$state->start || $state->start > $state->maxId) {
$state->step++;
$state->start = 0;
}
if ($this->checkTimeout()) break;
}
$app->setUserState ( 'com_kunena.admin.recount', $state );
$this->setRedirect(KunenaRoute::_('index.php?option=com_kunena&view=recount&task=recount', false));
}
示例3: before
/**
* Prepare category display.
*
* @return void
*
* @throws KunenaExceptionAuthorise
*/
protected function before()
{
parent::before();
require_once KPATH_SITE . '/models/category.php';
$this->model = new KunenaModelCategory();
$this->me = KunenaUserHelper::getMyself();
$catid = $this->input->getInt('catid');
$limitstart = $this->input->getInt('limitstart', 0);
$limit = $this->input->getInt('limit', 0);
if ($limit < 1 || $limit > 100) {
$limit = $this->config->threads_per_page;
}
// TODO:
$direction = 'DESC';
$this->category = KunenaForumCategoryHelper::get($catid);
$this->category->tryAuthorise();
$this->headerText = JText::_('COM_KUNENA_THREADS_IN_FORUM') . ': ' . $this->category->name;
$topic_ordering = $this->category->topic_ordering;
$access = KunenaAccess::getInstance();
$hold = $access->getAllowedHold($this->me, $catid);
$moved = 1;
$params = array('hold' => $hold, 'moved' => $moved);
switch ($topic_ordering) {
case 'alpha':
$params['orderby'] = 'tt.ordering DESC, tt.subject ASC ';
break;
case 'creation':
$params['orderby'] = 'tt.ordering DESC, tt.first_post_time ' . $direction;
break;
case 'lastpost':
default:
$params['orderby'] = 'tt.ordering DESC, tt.last_post_time ' . $direction;
}
list($this->total, $this->topics) = KunenaForumTopicHelper::getLatestTopics($catid, $limitstart, $limit, $params);
if ($this->total > 0) {
// Collect user ids for avatar prefetch when integrated.
$userlist = array();
$lastpostlist = array();
foreach ($this->topics as $topic) {
$userlist[intval($topic->first_post_userid)] = intval($topic->first_post_userid);
$userlist[intval($topic->last_post_userid)] = intval($topic->last_post_userid);
$lastpostlist[intval($topic->last_post_id)] = intval($topic->last_post_id);
}
// Prefetch all users/avatars to avoid user by user queries during template iterations.
if (!empty($userlist)) {
KunenaUserHelper::loadUsers($userlist);
}
KunenaForumTopicHelper::getUserTopics(array_keys($this->topics));
KunenaForumTopicHelper::getKeywords(array_keys($this->topics));
$lastreadlist = KunenaForumTopicHelper::fetchNewStatus($this->topics);
// Fetch last / new post positions when user can see unapproved or deleted posts.
if ($lastreadlist || $this->me->isAdmin() || KunenaAccess::getInstance()->getModeratorStatus()) {
KunenaForumMessageHelper::loadLocation($lastpostlist + $lastreadlist);
}
}
$this->topicActions = $this->model->getTopicActions();
$this->actionMove = $this->model->getActionMove();
$this->pagination = new KunenaPagination($this->total, $limitstart, $limit);
$this->pagination->setDisplayedPages(5);
}
示例4: getCategories
/**
* Get categories for a specific user.
*
* @param bool|array|int $ids The category ids to load.
* @param mixed $user The user id to load.
*
* @return KunenaForumCategoryUser[]
*/
static public function getCategories($ids = false, $user = null)
{
$user = KunenaUserHelper::get($user);
if ($ids === false)
{
// Get categories which are seen by current user
$ids = KunenaForumCategoryHelper::getCategories();
}
elseif (!is_array ($ids) )
{
$ids = array($ids);
}
// Convert category objects into ids
foreach ($ids as $i => $id)
{
if ($id instanceof KunenaForumCategory) $ids[$i] = $id->id;
}
$ids = array_unique($ids);
self::loadCategories($ids, $user);
$list = array ();
foreach ( $ids as $id )
{
if (!empty(self::$_instances [$user->userid][$id])) {
$list [$id] = self::$_instances [$user->userid][$id];
}
}
return $list;
}
示例5: before
/**
* Prepare category display.
*
* @return void
*
* @throws KunenaExceptionAuthorise
*/
protected function before()
{
parent::before();
require_once KPATH_SITE . '/models/category.php';
$catid = $this->input->getInt('catid');
$this->category = KunenaForumCategoryHelper::get($catid);
$this->category->tryAuthorise();
}
示例6: testGetCategories
/**
* Test getCategories()
*/
public function testGetCategories() {
$categories = KunenaForumCategoryHelper::getCategories();
$categoryusers = KunenaForumCategoryUserHelper::getCategories();
foreach ($categories as $category) {
$this->assertTrue(isset($categoryusers[$category->id]));
$this->assertEquals($category->id, $categoryusers[$category->id]->category_id);
}
}
示例7: testGetAllCategories
/**
* Test getCategories()
*/
public function testGetAllCategories() {
$categories = KunenaForumCategoryHelper::getCategories();
$this->assertInternalType('array', $categories);
foreach ($categories as $id=>$category) {
$this->assertEquals($id, $category->id);
$this->assertTrue($category->exists());
$this->assertSame($category, KunenaForumCategoryHelper::get($id));
}
}
示例8: check
function check() {
$user = KunenaUserHelper::get($this->user_id);
if (!$user->exists()) {
$this->setError ( JText::sprintf ( 'COM_KUNENA_LIB_TABLE_USERCATEGORIES_ERROR_USER_INVALID', (int) $user->userid ) );
}
if ($this->category_id && !KunenaForumCategoryHelper::get($this->category_id)->exists()) {
$this->setError ( JText::sprintf ( 'COM_KUNENA_LIB_TABLE_USERCATEGORIES_ERROR_CATEGORY_INVALID', (int) $category->id ) );
}
return ($this->getError () == '');
}
示例9: getCategories
/**
* @return array
*/
public function getCategories()
{
$rows = \KunenaForumCategoryHelper::getChildren( 0, 10, array( 'action' => 'admin', 'unpublished' => true ) );
$options = array();
foreach ( $rows as $row ) {
$options[] = \moscomprofilerHTML::makeOption( (string) $row->id, str_repeat( '- ', $row->level + 1 ) . ' ' . $row->name );
}
return $options;
}
示例10: displayTopicIcons
/**
* Send list of topic icons in JSON for the category set selected
*
* @return string
*/
public function displayTopicIcons()
{
jimport('joomla.filesystem.folder');
$catid = $this->app->input->getInt('catid', 0);
$category = KunenaForumCategoryHelper::get($catid);
$category_iconset = $category->iconset;
if (empty($category_iconset)) {
$response = array();
// Set the MIME type and header for JSON output.
$this->document->setMimeEncoding('application/json');
JResponse::setHeader('Content-Disposition', 'attachment; filename="' . $this->getName() . '.' . $this->getLayout() . '.json"');
echo json_encode($response);
}
$topicIcons = array();
$template = KunenaFactory::getTemplate();
$xmlfile = JPATH_ROOT . '/media/kunena/topic_icons/' . $category_iconset . '/topicicons.xml';
if (is_file($xmlfile)) {
$xml = simplexml_load_file($xmlfile);
foreach ($xml->icons as $icons) {
$type = (string) $icons->attributes()->type;
$width = (int) $icons->attributes()->width;
$height = (int) $icons->attributes()->height;
foreach ($icons->icon as $icon) {
$attributes = $icon->attributes();
$icon = new stdClass();
$icon->id = (int) $attributes->id;
$icon->type = (string) $attributes->type ? (string) $attributes->type : $type;
$icon->name = (string) $attributes->name;
if ($icon->type != 'user') {
$icon->id = $icon->type . '_' . $icon->name;
}
$icon->iconset = $category_iconset;
$icon->published = (int) $attributes->published;
$icon->title = (string) $attributes->title;
$icon->b2 = (string) $attributes->b2;
$icon->b3 = (string) $attributes->b3;
$icon->fa = (string) $attributes->fa;
$icon->filename = (string) $attributes->src;
$icon->width = (int) $attributes->width ? (int) $attributes->width : $width;
$icon->height = (int) $attributes->height ? (int) $attributes->height : $height;
$icon->path = JURI::root() . 'media/kunena/topic_icons/' . $category_iconset . '/' . $icon->filename;
$icon->relpath = $template->getTopicIconPath("{$icon->filename}", false, $category_iconset);
$topicIcons[] = $icon;
}
}
}
// Set the MIME type and header for JSON output.
$this->document->setMimeEncoding('application/json');
JResponse::setHeader('Content-Disposition', 'attachment; filename="' . $this->getName() . '.' . $this->getLayout() . '.json"');
echo json_encode($topicIcons);
}
示例11: check
public function check()
{
$category = KunenaForumCategoryHelper::get($this->category_id);
if (!$category->exists()) {
$this->setError(JText::sprintf('COM_KUNENA_LIB_TABLE_TOPICS_ERROR_CATEGORY_INVALID', $category->id));
} else {
$this->category_id = $category->id;
}
$this->subject = trim($this->subject);
if (!$this->subject) {
$this->setError(JText::sprintf('COM_KUNENA_LIB_TABLE_TOPICS_ERROR_NO_SUBJECT'));
}
return $this->getError() == '';
}
示例12: before
/**
* Redirect unread layout to the page that contains the first unread message.
*
* @return void
*
* @throws KunenaExceptionAuthorise
*/
protected function before()
{
$catid = $this->input->getInt('catid', 0);
$id = $this->input->getInt('id', 0);
$category = KunenaForumCategoryHelper::get($catid);
$category->tryAuthorise();
$topic = KunenaForumTopicHelper::get($id);
$topic->tryAuthorise();
KunenaForumTopicHelper::fetchNewStatus(array($topic->id => $topic));
$message = KunenaForumMessageHelper::get($topic->lastread ? $topic->lastread : $topic->last_post_id);
$message->tryAuthorise();
while (@ob_end_clean()) {
}
$this->app->redirect($topic->getUrl($category, false, $message));
}
示例13: save
function save() {
$db = JFactory::getDBO ();
$app = JFactory::getApplication ();
if (! JRequest::checkToken ()) {
$app->enqueueMessage ( JText::_ ( 'COM_KUNENA_ERROR_TOKEN' ), 'error' );
$app->redirect ( KunenaRoute::_($this->baseurl, false) );
}
$newview = JRequest::getVar ( 'newview' );
$newrank = JRequest::getVar ( 'newrank' );
$signature = JRequest::getVar ( 'message' );
$deleteSig = JRequest::getVar ( 'deleteSig' );
$moderator = JRequest::getInt ( 'moderator' );
$uid = JRequest::getInt ( 'uid' );
$avatar = JRequest::getVar ( 'avatar' );
$deleteAvatar = JRequest::getVar ( 'deleteAvatar' );
$neworder = JRequest::getInt ( 'neworder' );
$modCatids = $moderator ? JRequest::getVar ( 'catid', array () ) : array();
if ($deleteSig == 1) {
$signature = "";
}
$avatar = '';
if ($deleteAvatar == 1) {
$avatar = ",avatar=''";
}
$db->setQuery ( "UPDATE #__kunena_users SET signature={$db->quote($signature)}, view='$newview', ordering='$neworder', rank='$newrank' $avatar WHERE userid='$uid'" );
$db->query ();
if (KunenaError::checkDatabaseError()) return;
$app->enqueueMessage ( JText::_ ( 'COM_KUNENA_USER_PROFILE_SAVED_SUCCESSFULLY' ) );
// Update moderator rights
$me = KunenaUserHelper::getMyself();
$categories = KunenaForumCategoryHelper::getCategories(false, false, 'admin');
$user = KunenaFactory::getUser($uid);
foreach ($categories as $category) {
$category->setModerator($user, in_array($category->id, $modCatids));
}
// Global moderator is a special case
if ($me->isAdmin()) {
KunenaFactory::getAccessControl()->setModerator(0, $user, in_array(0, $modCatids));
}
$app->redirect ( KunenaRoute::_($this->baseurl, false) );
}
示例14: before
/**
* Prepare category subscriptions display.
*
* @return void
*
* @throws KunenaExceptionAuthorise
*/
protected function before()
{
parent::before();
$me = KunenaUserHelper::getMyself();
if (!$me->exists()) {
throw new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), 401);
}
$limit = $this->input->getInt('limit', 0);
if ($limit < 1 || $limit > 100) {
$limit = 20;
}
$limitstart = $this->input->getInt('limitstart', 0);
if ($limitstart < 0) {
$limitstart = 0;
}
list($total, $this->categories) = KunenaForumCategoryHelper::getLatestSubscriptions($me->userid);
$topicIds = array();
$userIds = array();
$postIds = array();
foreach ($this->categories as $category) {
// Get list of topics.
if ($category->last_topic_id) {
$topicIds[$category->last_topic_id] = $category->last_topic_id;
}
}
// Pre-fetch topics (also display unauthorized topics as they are in allowed categories).
$topics = KunenaForumTopicHelper::getTopics($topicIds, 'none');
// Pre-fetch users (and get last post ids for moderators).
foreach ($topics as $topic) {
$userIds[$topic->last_post_userid] = $topic->last_post_userid;
$postIds[$topic->id] = $topic->last_post_id;
}
KunenaUserHelper::loadUsers($userIds);
KunenaForumMessageHelper::getMessages($postIds);
// Pre-fetch user related stuff.
if ($me->exists() && !$me->isBanned()) {
// Load new topic counts.
KunenaForumCategoryHelper::getNewTopics(array_keys($this->categories));
}
$this->actions = $this->getActions();
$this->pagination = new JPagination($total, $limitstart, $limit);
$this->headerText = JText::_('COM_KUNENA_CATEGORY_SUBSCRIPTIONS');
}
示例15: getCategoryTree
/**
* @param XmapDisplayerInterface $xmap
* @param stdClass $parent
* @param array $params
* @param int $catid
*/
private static function getCategoryTree($xmap, stdClass $parent, array &$params, $catid)
{
/** @var KunenaForumCategory[] $categories */
$categories = KunenaForumCategoryHelper::getChildren($catid);
$xmap->changeLevel(1);
foreach ($categories as $cat) {
$node = new stdClass();
$node->id = $parent->id;
$node->browserNav = $parent->browserNav;
$node->uid = $parent->uid . '_c_' . $cat->id;
$node->name = $cat->name;
$node->priority = $params['cat_priority'];
$node->changefreq = $params['cat_changefreq'];
$node->link = 'index.php?option=com_kunena&view=category&catid=' . $cat->id . '&Itemid=' . $parent->id;
$node->secure = $parent->secure;
if ($xmap->printNode($node)) {
self::getTopics($xmap, $parent, $params, $cat->id);
}
}
$xmap->changeLevel(-1);
}