当前位置: 首页>>代码示例>>PHP>>正文


PHP KunenaForumCategoryHelper::get方法代码示例

本文整理汇总了PHP中KunenaForumCategoryHelper::get方法的典型用法代码示例。如果您正苦于以下问题:PHP KunenaForumCategoryHelper::get方法的具体用法?PHP KunenaForumCategoryHelper::get怎么用?PHP KunenaForumCategoryHelper::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在KunenaForumCategoryHelper的用法示例。


在下文中一共展示了KunenaForumCategoryHelper::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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);
 }
开发者ID:anawu2006,项目名称:PeerLearning,代码行数:67,代码来源:display.php

示例2: 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();
 }
开发者ID:giabmf11,项目名称:Kunena-Forum,代码行数:15,代码来源:display.php

示例3: 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));
		}
	}
开发者ID:GoremanX,项目名称:Kunena-2.0,代码行数:12,代码来源:KunenaForumCategoryHelperTest.php

示例4: 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 () == '');
	}
开发者ID:GoremanX,项目名称:Kunena-2.0,代码行数:10,代码来源:kunenausercategories.php

示例5: 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);
 }
开发者ID:Ruud68,项目名称:Kunena-Forum,代码行数:56,代码来源:view.raw.php

示例6: 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() == '';
 }
开发者ID:sillysachin,项目名称:teamtogether,代码行数:14,代码来源:kunenatopics.php

示例7: 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));
 }
开发者ID:giabmf11,项目名称:Kunena-Forum,代码行数:22,代码来源:display.php

示例8: subscribe

 function subscribe()
 {
     if (!JSession::checkToken('get')) {
         $this->app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error');
         $this->redirectBack();
     }
     $category = KunenaForumCategoryHelper::get(JRequest::getInt('catid', 0));
     if (!$category->authorise('read')) {
         $this->app->enqueueMessage($category->getError(), 'error');
         $this->redirectBack();
     }
     if ($this->me->exists()) {
         $success = $category->subscribe(1);
         if ($success) {
             $this->app->enqueueMessage(JText::_('COM_KUNENA_GEN_CATEGORY_SUBCRIBED'));
         }
     }
     $this->redirectBack();
 }
开发者ID:proyectoseb,项目名称:University,代码行数:19,代码来源:category.php

示例9: doprune

	function doprune() {
		$app = JFactory::getApplication ();
		if (!JRequest::checkToken()) {
			$app->enqueueMessage ( JText::_ ( 'COM_KUNENA_ERROR_TOKEN' ), 'error' );
			$this->setRedirect(KunenaRoute::_($this->baseurl, false));
			return;
		}
		$category = KunenaForumCategoryHelper::get(JRequest::getInt ( 'prune_forum', 0 ));
		if (!$category->authorise('admin')) {
			$app->enqueueMessage ( JText::_ ( 'COM_KUNENA_CHOOSEFORUMTOPRUNE' ), 'error' );
			$this->setRedirect(KunenaRoute::_($this->baseurl, false));
			return;
		}

		// Convert days to seconds for timestamp functions...
		$prune_days = JRequest::getInt ( 'prune_days', 36500 );
		$prune_date = JFactory::getDate()->toUnix() - ($prune_days * 86400);

		$trashdelete = JRequest::getInt( 'trashdelete', 0);

		// Get up to 100 oldest topics to be deleted
		$params = array(
			'orderby'=>'tt.last_post_time ASC',
			'where'=>"AND tt.last_post_time<{$prune_date} AND ordering=0",
		);
		list($count, $topics) = KunenaForumTopicHelper::getLatestTopics($category->id, 0, 100, $params);
		$deleted = 0;
		foreach ( $topics as $topic ) {
			$deleted++;
			if ( $trashdelete ) $topic->delete(false);
			else $topic->trash();
		}
		KunenaUserHelper::recount();
		KunenaForumCategoryHelper::recount();
		KunenaForumMessageAttachmentHelper::cleanup();
		if ( $trashdelete ) $app->enqueueMessage ( "" . JText::_('COM_KUNENA_FORUMPRUNEDFOR') . " " . $prune_days . " " . JText::_('COM_KUNENA_PRUNEDAYS') . "; " . JText::_('COM_KUNENA_PRUNEDELETED') . " {$deleted}/{$count} " . JText::_('COM_KUNENA_PRUNETHREADS') );
		else $app->enqueueMessage ( "" . JText::_('COM_KUNENA_FORUMPRUNEDFOR') . " " . $prune_days . " " . JText::_('COM_KUNENA_PRUNEDAYS') . "; " . JText::_('COM_KUNENA_PRUNETRASHED') . " {$deleted}/{$count} " . JText::_('COM_KUNENA_PRUNETHREADS') );
		$this->setRedirect(KunenaRoute::_($this->baseurl, false));
	}
开发者ID:rich20,项目名称:Kunena,代码行数:39,代码来源:prune.php

示例10: DisplayCreate

 protected function DisplayCreate($tpl = null)
 {
     $this->setLayout('edit');
     // Get captcha
     $captcha = KunenaSpamRecaptcha::getInstance();
     if ($captcha->enabled()) {
         $this->captchaHtml = $captcha->getHtml();
         if (!$this->captchaHtml) {
             $this->app->enqueueMessage($captcha->getError(), 'error');
             $this->redirectBack();
             return;
         }
     }
     // Get saved message
     $saved = $this->app->getUserState('com_kunena.postfields');
     // Get topic icons if allowed
     if ($this->config->topicicons) {
         $this->topicIcons = $this->ktemplate->getTopicIcons(false, $saved ? $saved['icon_id'] : 0);
     }
     $categories = KunenaForumCategoryHelper::getCategories();
     $arrayanynomousbox = array();
     $arraypollcatid = array();
     foreach ($categories as $category) {
         if (!$category->isSection() && $category->allow_anonymous) {
             $arrayanynomousbox[] = '"' . $category->id . '":' . $category->post_anonymous;
         }
         if (!$category->isSection() && $category->allow_polls) {
             $arraypollcatid[] = '"' . $category->id . '":1';
         }
     }
     $arrayanynomousbox = implode(',', $arrayanynomousbox);
     $arraypollcatid = implode(',', $arraypollcatid);
     $this->document->addScriptDeclaration('var arrayanynomousbox={' . $arrayanynomousbox . '}');
     $this->document->addScriptDeclaration('var pollcategoriesid = {' . $arraypollcatid . '};');
     $cat_params = array('ordering' => 'ordering', 'toplevel' => 0, 'sections' => 0, 'direction' => 1, 'hide_lonely' => 1, 'action' => 'topic.create');
     $this->catid = $this->state->get('item.catid');
     $this->category = KunenaForumCategoryHelper::get($this->catid);
     list($this->topic, $this->message) = $this->category->newTopic($saved);
     if (!$this->topic->category_id) {
         $msg = JText::sprintf('COM_KUNENA_POST_NEW_TOPIC_NO_PERMISSIONS', $this->topic->getError());
         $this->app->enqueueMessage($msg, 'notice');
         return false;
     }
     $options = array();
     $selected = $this->topic->category_id;
     if ($this->config->pickup_category) {
         $options[] = JHtml::_('select.option', '', JText::_('COM_KUNENA_SELECT_CATEGORY'), 'value', 'text');
         $selected = 0;
     }
     if ($saved) {
         $selected = $saved['catid'];
     }
     $this->selectcatlist = JHtml::_('kunenaforum.categorylist', 'catid', $this->catid, $options, $cat_params, 'class="inputbox required"', 'value', 'text', $selected, 'postcatid');
     $this->_prepareDocument('create');
     $this->action = 'post';
     $this->allowedExtensions = KunenaAttachmentHelper::getExtensions($this->category);
     if ($arraypollcatid) {
         $this->poll = $this->topic->getPoll();
     }
     $this->post_anonymous = $saved ? $saved['anonymous'] : !empty($this->category->post_anonymous);
     $this->subscriptionschecked = $saved ? $saved['subscribe'] : $this->config->subscriptionschecked == 1;
     $this->app->setUserState('com_kunena.postfields', null);
     $this->render('Topic/Edit', $tpl);
 }
开发者ID:Jougito,项目名称:DynWeb,代码行数:64,代码来源:view.html.php

示例11: getUri

 /**
  * @param mixed $category
  * @param string $action
  *
  * @return JUri|null
  */
 public function getUri($category = null, $action = null)
 {
     $category = $category ? KunenaForumCategoryHelper::get($category) : $this->getCategory();
     $Itemid = KunenaRoute::getCategoryItemid($category);
     if (!$this->exists() || !$category->exists()) {
         return null;
     }
     if ($action instanceof KunenaForumMessage) {
         $message = $action;
         $action = 'post' . $message->id;
     }
     $uri = JUri::getInstance("index.php?option=com_kunena&view=topic&catid={$category->id}&id={$this->id}&action={$action}&Itemid={$Itemid}");
     if ($uri->getVar('action') !== null) {
         $uri->delVar('action');
         $mesid = 0;
         $limit = max(1, intval(KunenaFactory::getConfig()->messages_per_page));
         if (isset($message)) {
             $mesid = $message->id;
         } elseif ((string) $action === (string) (int) $action) {
             if ($action > 0) {
                 $uri->setVar('limitstart', $action * $limit);
             }
         } else {
             switch ($action) {
                 case 'first':
                     $mesid = $this->first_post_id;
                     break;
                 case 'last':
                     $mesid = $this->last_post_id;
                     break;
                 case 'unread':
                     // Special case, improves caching
                     $uri->setVar('layout', 'unread');
                     // $mesid = $this->lastread ? $this->lastread : $this->last_post_id;
                     break;
             }
         }
         if ($mesid) {
             if (KunenaUserHelper::getMyself()->getTopicLayout() != 'threaded' && $mesid > 0) {
                 $uri->setFragment($mesid);
                 $limitstart = intval($this->getPostLocation($mesid) / $limit) * $limit;
                 if ($limitstart) {
                     $uri->setVar('limitstart', $limitstart);
                 }
             } else {
                 $uri->setVar('mesid', $mesid);
             }
         }
     }
     return $uri;
 }
开发者ID:giabmf11,项目名称:Kunena-Forum,代码行数:57,代码来源:topic.php

示例12: KunenaParseRoute

function KunenaParseRoute($segments) {
	$profiler = JProfiler::getInstance('Application');
	KUNENA_PROFILER ? $profiler->mark('kunenaRoute') : null;
	$starttime = $profiler->getmicrotime();

	// Get current menu item and get query variables from it
	$active = JFactory::getApplication()->getMenu ()->getActive ();
	$vars = isset ( $active->query ) ? $active->query : array ('view'=>'home');
	if (empty($vars['view']) || $vars['view']=='home' || $vars['view']=='entrypage') {
		$vars['view'] = '';
	}

	// Fix bug in Joomla 1.5 when using /components/kunena instead /component/kunena
	if (!$active && $segments[0] == 'kunena') array_shift ( $segments );

	// Enable SEF category feature
	$sefcats = KunenaRoute::$config->sefcats && isset(KunenaRouter::$sefviews[$vars['view']]) && empty($vars ['id']);

	// Handle all segments
	while ( ($segment = array_shift ( $segments )) !== null ) {
		$seg = explode ( ':', $segment );
		$var = array_shift ( $seg );
		$value = array_shift ( $seg );

		if (is_numeric ( $var )) {
			$value = (int) $var;
			if ($vars['view'] == 'user') {
				$var = 'userid';
			} else {
				// Numeric variable is always catid or id
				if (empty($vars ['catid'])
					|| (empty($vars ['id']) && KunenaForumCategoryHelper::get($value)->exists() && KunenaForumTopicHelper::get($value)->category_id != $vars ['catid'])) {
					// First numbers are always categories
					// FIXME: what if $topic->catid == catid
					$var = 'catid';
					$vars ['view'] = 'category';
				} elseif (empty($vars ['id'])) {
					// Next number is always topic
					$var = 'id';
					$vars ['view'] = 'topic';
					$sefcats = false;
				} elseif (empty($vars ['mesid'])) {
					// Next number is always message
					$var = 'mesid';
					$vars ['view'] = 'topic';
				} else {
					// Invalid parameter, skip it
					continue;
				}
			}
		} elseif (empty ( $var ) && empty ( $value )) {
			// Empty parameter, skip it
			continue;
		} elseif ($sefcats && (($value !== null && ! isset ( KunenaRouter::$parsevars[$var] ))
		|| ($value === null && ! isset ( KunenaRouter::$views[$var] ) && ! isset ( KunenaRouter::$layouts[$var] ) && ! isset ( KunenaRouter::$functions[$var] )))) {
			// We have SEF category: translate category name into catid=123
			// TODO: cache filtered values to gain some speed -- I would like to start using category names instead of catids if it gets fast enough
			$var = 'catid';
			$value = -1;
			$catname = strtr ( $segment, ':', '-' );
			$categories = empty($vars ['catid']) ? KunenaForumCategoryHelper::getCategories() : KunenaForumCategoryHelper::getChildren($vars ['catid']);
			foreach ( $categories as $category ) {
				if ($catname == KunenaRouter::filterOutput ( $category->name ) || $catname == JFilterOutput::stringURLSafe ( $category->name )) {
					$value = (int) $category->id;
					break;
				}
			}
			$vars ['view'] = 'category';
		} elseif ($value === null) {
			// Variable must be either view or layout
			$sefcats = false;
			$value = $var;
			if (empty($vars ['view']) || ($value=='topic' && $vars ['view'] == 'category')) {
				$var = 'view';
			} elseif (empty($vars ['layout'])) {
				$var = 'layout';
			} else {
				// Unknown parameter: continue
				if (!empty($vars ['view'])) continue;
				// Oops: unknown view or non-existing category
				$var = 'view';
			}
		}
		$vars [$var] = $value;
	}
	if (empty($vars ['layout'])) $vars ['layout'] = 'default';
	KunenaRouter::$time = $profiler->getmicrotime() - $starttime;
	return $vars;
}
开发者ID:rich20,项目名称:Kunena,代码行数:89,代码来源:router.php

示例13: orderUpDown

	protected function orderUpDown($id, $direction)
	{
		KunenaFactory::loadLanguage('com_kunena', 'admin');

		if (!$id)
		{
			return;
		}

		if (!JSession::checkToken('post'))
		{
			$this->app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error');

			return;
		}

		$category = KunenaForumCategoryHelper::get($id);

		if (!$category->getParent()->authorise('admin'))
		{
			$this->app->enqueueMessage(JText::sprintf('COM_KUNENA_A_CATEGORY_NO_ADMIN', $this->escape($category->getParent()->name)), 'notice');

			return;
		}

		if ($category->isCheckedOut($this->me->userid))
		{
			$this->app->enqueueMessage(JText::sprintf('COM_KUNENA_A_CATEGORY_X_CHECKED_OUT', $this->escape($category->name)), 'notice');

			return;
		}

		$db  = JFactory::getDBO();
		$row = new TableKunenaCategories ($db);
		$row->load($id);

		// Ensure that we have the right ordering
		$where = 'parent_id=' . $db->quote($row->parent_id);
		$row->reorder();
		$row->move($direction, $where);
	}
开发者ID:BillVGN,项目名称:PortalPRP,代码行数:41,代码来源:categories.php

示例14: check

	function check() {
		$category = KunenaForumCategoryHelper::get($this->catid);
		if (!$category->exists()) {
			// TODO: maybe we should have own error message? or not?
			$this->setError ( JText::sprintf ( 'COM_KUNENA_LIB_TABLE_TOPICS_ERROR_CATEGORY_INVALID', $this->catid ) );
		} else {
			$this->catid = $category->id;
		}
		$this->subject = trim($this->subject);
		if (!$this->subject) {
			$this->setError ( JText::_ ( 'COM_KUNENA_LIB_TABLE_MESSAGES_ERROR_NO_SUBJECT' ) );
		}
		$this->message = trim($this->message);
		if (!$this->message) {
			$this->setError ( JText::_ ( 'COM_KUNENA_LIB_TABLE_MESSAGES_ERROR_NO_MESSAGE' ) );
		}
		if (!$this->time) {
			$this->time = JFactory::getDate()->toUnix();
		}
		$this->modified_reason = trim($this->modified_reason);
		return ($this->getError () == '');
	}
开发者ID:GoremanX,项目名称:Kunena-2.0,代码行数:22,代码来源:kunenamessages.php

示例15: categorylist

 public static function categorylist($name, $parent, $options = array(), $params = array(), $attribs = null, $key = 'value', $text = 'text', $selected = array(), $idtag = false, $translate = false)
 {
     $unpublished = isset($params['unpublished']) ? (bool) $params['unpublished'] : 0;
     $sections = isset($params['sections']) ? (bool) $params['sections'] : 0;
     $ordering = isset($params['ordering']) ? (string) $params['ordering'] : 'ordering';
     $direction = isset($params['direction']) && $params['direction'] == 'desc' ? -1 : 1;
     $action = isset($params['action']) ? (string) $params['action'] : 'read';
     $levels = isset($params['levels']) ? (int) $params['levels'] : 10;
     $topleveltxt = isset($params['toplevel']) ? $params['toplevel'] : false;
     $catid = isset($params['catid']) ? (int) $params['catid'] : 0;
     $hide_lonely = isset($params['hide_lonely']) ? (bool) $params['hide_lonely'] : 0;
     $params = array();
     $params['ordering'] = $ordering;
     $params['direction'] = $direction;
     $params['unpublished'] = $unpublished;
     $params['action'] = $action;
     $params['selected'] = $catid;
     if ($catid) {
         $category = KunenaForumCategoryHelper::get($catid);
         if (!$category->getParent()->authorise($action) && !KunenaUserHelper::getMyself()->isAdmin()) {
             $categories = KunenaForumCategoryHelper::getParents($catid, $levels, $params);
         }
     }
     $channels = array();
     if (!isset($categories)) {
         $category = KunenaForumCategoryHelper::get($parent);
         $children = KunenaForumCategoryHelper::getChildren($parent, $levels, $params);
         if ($params['action'] == 'topic.create') {
             $channels = $category->getChannels();
             if (empty($children) && !isset($channels[$category->id])) {
                 $category = KunenaForumCategoryHelper::get();
             }
             foreach ($channels as $id => $channel) {
                 if (!$id || $category->id == $id || isset($children[$id]) || !$channel->authorise($action)) {
                     unset($channels[$id]);
                 }
             }
         }
         $categories = $category->id > 0 ? array($category->id => $category) + $children : $children;
         if ($hide_lonely && count($categories) + count($channels) <= 1) {
             return;
         }
     }
     if (!is_array($options)) {
         $options = array();
     }
     if ($selected === false || $selected === null) {
         $selected = array();
     } elseif (!is_array($selected)) {
         $selected = array((string) $selected);
     }
     if ($topleveltxt) {
         $me = KunenaUserHelper::getMyself();
         $disabled = $action == 'admin' && !$me->isAdmin();
         $options[] = JHtml::_('select.option', '0', JText::_($topleveltxt), 'value', 'text', $disabled);
         if (empty($selected) && !$disabled) {
             $selected[] = 0;
         }
         $toplevel = 1;
     } else {
         $toplevel = -KunenaForumCategoryHelper::get($parent)->level;
     }
     foreach ($categories as $category) {
         $disabled = !$category->authorise($action) || !$sections && $category->isSection();
         if (empty($selected) && !$disabled) {
             $selected[] = $category->id;
         }
         $options[] = JHtml::_('select.option', $category->id, str_repeat('- ', $category->level + $toplevel) . ' ' . $category->name, 'value', 'text', $disabled);
     }
     $disabled = false;
     foreach ($channels as $category) {
         if (empty($selected)) {
             $selected[] = $category->id;
         }
         $options[] = JHtml::_('select.option', $category->id, '+ ' . $category->getParent()->name . ' / ' . $category->name, 'value', 'text', $disabled);
     }
     reset($options);
     if (is_array($attribs)) {
         $attribs = JArrayHelper::toString($attribs);
     }
     $id = $name;
     if ($idtag) {
         $id = $idtag;
     }
     $id = str_replace('[', '', $id);
     $id = str_replace(']', '', $id);
     $html = '';
     if (!empty($options)) {
         $html .= '<select name="' . $name . '" id="' . $id . '" ' . $attribs . '>';
         $html .= JHtml::_('select.options', $options, $key, $text, $selected, $translate);
         $html .= '</select>';
     }
     return $html;
 }
开发者ID:madcsaba,项目名称:li-de,代码行数:94,代码来源:kunenaforum.php


注:本文中的KunenaForumCategoryHelper::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。