本文整理汇总了PHP中KunenaForumCategoryHelper::getParents方法的典型用法代码示例。如果您正苦于以下问题:PHP KunenaForumCategoryHelper::getParents方法的具体用法?PHP KunenaForumCategoryHelper::getParents怎么用?PHP KunenaForumCategoryHelper::getParents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KunenaForumCategoryHelper
的用法示例。
在下文中一共展示了KunenaForumCategoryHelper::getParents方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: defined
<?php
/**
* Kunena Component
* @package Kunena.Template.Crypsis
* @subpackage Pages.Topic
*
* @copyright (C) 2008 - 2016 Kunena Team. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* @link https://www.kunena.org
**/
defined('_JEXEC') or die;
$content = $this->execute('Topic/Form/Reply');
// Display breadcrumb path to the current category / topic / message / moderate.
$parents = KunenaForumCategoryHelper::getParents($content->category->id);
$parents[] = $content->category;
/** @var KunenaForumCategory $parent */
foreach ($parents as $parent)
{
$this->addBreadcrumb(
$parent->displayField('name'),
$parent->getUri()
);
}
$this->addBreadcrumb(
$content->topic->subject,
$content->topic->getUri()
);
示例2: displayBreadcrumb
function displayBreadcrumb($tpl = null) {
$catid = JRequest::getInt ( 'catid', 0 );
$id = JRequest::getInt ( 'id', 0 );
$view = JRequest::getWord ( 'view', 'default' );
$layout = JRequest::getWord ( 'layout', 'default' );
$app = JFactory::getApplication();
$pathway = $app->getPathway();
$active = JFactory::getApplication()->getMenu ()->getActive ();
if (empty($this->pathway)) {
if ($catid) {
$parents = KunenaForumCategoryHelper::getParents($catid);
$parents[$catid] = KunenaForumCategoryHelper::get($catid);
// Remove categories from pathway if menu item contains/excludes them
if (!empty($active->query['catid']) && isset($parents[$active->query['catid']])) {
$curcatid = $active->query['catid'];
while (($item = array_shift($parents)) !== null) {
if ($item->id == $curcatid) break;
}
}
foreach ( $parents as $parent ) {
$pathway->addItem($this->escape( $parent->name ), KunenaRoute::normalize("index.php?option=com_kunena&view=category&catid={$parent->id}"));
}
}
if ($id) {
$topic = KunenaForumTopicHelper::get($id);
$pathway->addItem($this->escape( $topic->subject ), KunenaRoute::normalize("index.php?option=com_kunena&view=category&catid={$catid}&id={$topic->id}"));
}
if ($view == 'topic') {
$active_layout = (!empty($active->query['view']) && $active->query['view'] == 'topic' && !empty($active->query['layout'])) ? $active->query['layout'] : '';
switch ($layout) {
case 'create':
if ($active_layout != 'create') $pathway->addItem($this->escape( JText::_('COM_KUNENA_BUTTON_NEW_TOPIC'), KunenaRoute::normalize() ));
break;
case 'reply':
if ($active_layout != 'reply') $pathway->addItem($this->escape( JText::_('COM_KUNENA_BUTTON_REPLY_TOPIC'), KunenaRoute::normalize() ));
break;
case 'edit':
if ($active_layout != 'edit') $pathway->addItem($this->escape( JText::_('COM_KUNENA_BUTTON_EDIT'), KunenaRoute::normalize() ));
break;
}
}
}
$this->pathway = array();
foreach ($pathway->getPathway() as $pitem) {
$item = new StdClass();
$item->name = $this->escape($pitem->name);
$item->link = KunenaRoute::_($pitem->link);
if ($item->link) $this->pathway[] = $item;
}
$result = $this->loadTemplate($tpl);
if (JError::isError($result)) {
return $result;
}
echo $result;
}
示例3: 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;
}
示例4: getAdminCategories
public function getAdminCategories()
{
if ($this->_admincategories === false) {
$params = array('ordering' => $this->getState('list.ordering'), 'direction' => $this->getState('list.direction') == 'asc' ? 1 : -1, 'search' => $this->getState('filter.search'), 'unpublished' => 1, 'published' => $this->getState('filter.published'), 'filter_title' => $this->getState('filter.title'), 'filter_type' => $this->getState('filter.type'), 'filter_access' => $this->getState('filter.access'), 'filter_locked' => $this->getState('filter.locked'), 'filter_allow_polls' => $this->getState('filter.allow_polls'), 'filter_review' => $this->getState('filter.review'), 'filter_anonymous' => $this->getState('filter.anonymous'), 'action' => 'admin');
$catid = $this->getState('item.id', 0);
$categories = array();
$orphans = array();
if ($catid) {
$categories = KunenaForumCategoryHelper::getParents($catid, $this->getState('filter.levels'), array('unpublished' => 1, 'action' => 'none'));
$categories[] = KunenaForumCategoryHelper::get($catid);
} else {
$orphans = KunenaForumCategoryHelper::getOrphaned($this->getState('filter.levels'), $params);
}
$categories = array_merge($categories, KunenaForumCategoryHelper::getChildren($catid, $this->getState('filter.levels'), $params));
$categories = array_merge($orphans, $categories);
$categories = KunenaForumCategoryHelper::getIndentation($categories);
$this->setState('list.total', count($categories));
if ($this->getState('list.limit')) {
$this->_admincategories = array_slice($categories, $this->getState('list.start'), $this->getState('list.limit'));
} else {
$this->_admincategories = $categories;
}
$admin = 0;
$acl = KunenaAccess::getInstance();
/** @var KunenaForumCategory $category */
foreach ($this->_admincategories as $category) {
// TODO: Following is needed for J!2.5 only:
$parent = $category->getParent();
$siblings = array_keys(KunenaForumCategoryHelper::getCategoryTree($category->parent_id));
$category->up = $this->me->isAdmin($parent) && reset($siblings) != $category->id;
$category->down = $this->me->isAdmin($parent) && end($siblings) != $category->id;
$category->reorder = $this->me->isAdmin($parent);
// Get ACL groups for the category.
$access = $acl->getCategoryAccess($category);
$category->accessname = array();
foreach ($access as $item) {
$category->accessname[] = $item['title'];
}
$category->accessname = implode(' / ', $category->accessname);
// Checkout?
if ($this->me->isAdmin($category) && $category->isCheckedOut(0)) {
$category->editor = KunenaFactory::getUser($category->checked_out)->getName();
} else {
$category->checked_out = 0;
$category->editor = '';
}
$admin += $this->me->isAdmin($category);
}
$this->setState('list.count.admin', $admin);
}
if (!empty($orphans)) {
$this->app->enqueueMessage(JText::_('COM_KUNENA_CATEGORY_ORPHAN_DESC'), 'notice');
}
return $this->_admincategories;
}
示例5: getAdminCategories
public function getAdminCategories() {
if ( $this->_admincategories === false ) {
$me = KunenaUserHelper::getMyself();
$params = array (
'ordering'=>$this->getState ( 'list.ordering' ),
'direction'=>$this->getState ( 'list.direction' ) == 'asc' ? 1 : -1,
'search'=>$this->getState ( 'list.search' ),
'unpublished'=>1,
'action'=>'admin');
$catid = $this->getState ( 'item.id', 0 );
$categories = array();
if ($catid) {
$categories = KunenaForumCategoryHelper::getParents($catid, $this->getState ( 'list.levels' ), array('unpublished'=>1, 'action'=>'none'));
$categories[] = KunenaForumCategoryHelper::get($catid);
}
$categories = array_merge($categories, KunenaForumCategoryHelper::getChildren($catid, $this->getState ( 'list.levels' ), $params));
$categories = KunenaForumCategoryHelper::getIndentation($categories);
$this->setState ( 'list.total', count($categories) );
$this->_admincategories = array_slice ( $categories, $this->getState ( 'list.start' ), $this->getState ( 'list.limit' ) );
$admin = 0;
$acl = KunenaFactory::getAccessControl();
foreach ($this->_admincategories as $category) {
$siblings = array_keys(KunenaForumCategoryHelper::getCategoryTree($category->parent_id));
if (empty($siblings)) {
// FIXME: deal with orphaned categories
$orphans = true;
$category->parent_id = 0;
$category->name = JText::_ ( 'COM_KUNENA_CATEGORY_ORPHAN' ) . ' : ' . $category->name;
}
$category->up = $me->isAdmin($category->parent_id) && reset($siblings) != $category->id;
$category->down = $me->isAdmin($category->parent_id) && end($siblings) != $category->id;
$category->reorder = $me->isAdmin($category->parent_id);
if ($category->accesstype == 'joomla.level') {
$groupname = $acl->getGroupName($category->accesstype, $category->access);
if (version_compare(JVERSION, '1.6','>')) {
// Joomla 1.6+
$category->accessname = JText::_('COM_KUNENA_INTEGRATION_JOOMLA_LEVEL').': '.($groupname ? $groupname : JText::_('COM_KUNENA_NOBODY'));
} else {
// Joomla 1.5
$category->accessname = JText::_('COM_KUNENA_INTEGRATION_JOOMLA_LEVEL').': '.($groupname ? JText::_($groupname) : JText::_('COM_KUNENA_NOBODY'));
}
} elseif ($category->accesstype != 'none') {
$category->accessname = JText::_('COM_KUNENA_INTEGRATION_'.strtoupper(preg_replace('/[^\w\d]+/', '_', $category->accesstype))).': '.$category->access;
} elseif (version_compare(JVERSION, '1.6','>')) {
// Joomla 1.6+
$groupname = $acl->getGroupName($category->accesstype, $category->pub_access);
$category->accessname = JText::sprintf( $category->pub_recurse ? 'COM_KUNENA_A_GROUP_X_PLUS' : 'COM_KUNENA_A_GROUP_X_ONLY', $groupname ? JText::_( $groupname ) : JText::_('COM_KUNENA_NOBODY') );
$groupname = $acl->getGroupName($category->accesstype, $category->admin_access);
if ($groupname && $category->pub_access != $category->admin_access) {
$category->accessname .= ' / '.JText::sprintf( $category->admin_recurse ? 'COM_KUNENA_A_GROUP_X_PLUS' : 'COM_KUNENA_A_GROUP_X_ONLY', JText::_( $groupname ));
}
} else {
// Joomla 1.5
$groupname = $acl->getGroupName($category->accesstype, $category->pub_access);
if ($category->pub_access == 0) {
$category->accessname = JText::_('COM_KUNENA_PUBLIC');
} else if ($category->pub_access == - 1) {
$category->accessname = JText::_('COM_KUNENA_ALLREGISTERED');
} else if ($category->pub_access == 1 || !$groupname) {
$category->accessname = JText::_('COM_KUNENA_NOBODY');
} else {
$category->accessname = JText::sprintf( $category->pub_recurse ? 'COM_KUNENA_A_GROUP_X_PLUS' : 'COM_KUNENA_A_GROUP_X_ONLY', JText::_( $groupname ));
}
$groupname = $acl->getGroupName($category->accesstype, $category->admin_access);
if ($category->pub_access > 0 && $groupname && $category->pub_access != $category->admin_access) {
$category->accessname .= ' / '.JText::sprintf( $category->admin_recurse ? 'COM_KUNENA_A_GROUP_X_PLUS' : 'COM_KUNENA_A_GROUP_X_ONLY', JText::_( $groupname ));
}
}
if ($category->accesstype != 'none') {
$category->admin_group = '';
} else {
$category->admin_group = JText::_ ( $acl->getGroupName($category->accesstype, $category->admin_access ));
}
if ($me->isAdmin($category->id) && $category->isCheckedOut(0)) {
$category->editor = KunenaFactory::getUser($category->checked_out)->getName();
} else {
$category->checked_out = 0;
$category->editor = '';
}
$admin += $me->isAdmin($category->id);
}
$this->setState ( 'list.count.admin', $admin );
}
if (isset($orphans)) {
$app = JFactory::getApplication ();
$app->enqueueMessage ( JText::_ ( 'COM_KUNENA_CATEGORY_ORPHAN_DESC' ), 'notice' );
}
return $this->_admincategories;
}
示例6: getAdminCategories
public function getAdminCategories() {
if ( $this->_admincategories === false ) {
$me = KunenaFactory::getUser();
$jversion = new JVersion ();
$params = array (
'ordering'=>$this->getState ( 'list.ordering' ),
'direction'=>$this->getState ( 'list.direction' ) == 'asc' ? 1 : -1,
'search'=>$this->getState ( 'list.search' ),
'unpublished'=>1,
'action'=>'admin');
$catid = $this->getState ( 'item.id', 0 );
$categories = array();
if ($catid) {
$categories = KunenaForumCategoryHelper::getParents($catid, $this->getState ( 'list.levels' ), array('unpublished'=>1, 'action'=>'none'));
$categories[] = KunenaForumCategoryHelper::get($catid);
}
$categories = array_merge($categories, KunenaForumCategoryHelper::getChildren($catid, $this->getState ( 'list.levels' ), $params));
$categories = KunenaForumCategoryHelper::getIndentation($categories);
$this->setState ( 'list.total', count($categories) );
$this->_admincategories = array_slice ( $categories, $this->getState ( 'list.start' ), $this->getState ( 'list.limit' ) );
$admin = 0;
$acl = KunenaFactory::getAccessControl();
foreach ($this->_admincategories as $category) {
$siblings = array_keys(KunenaForumCategoryHelper::getCategoryTree($category->parent_id));
if (empty($siblings)) {
// FIXME: deal with orphaned categories
$orphans = true;
$category->parent_id = 0;
$category->name = JText::_ ( 'COM_KUNENA_CATEGORY_ORPHAN' ) . ' : ' . $category->name;
}
$category->up = $me->isAdmin($category->parent_id) && reset($siblings) != $category->id;
$category->down = $me->isAdmin($category->parent_id) && end($siblings) != $category->id;
$category->reorder = $me->isAdmin($category->parent_id);
if ($category->accesstype != 'none') {
$category->pub_group = JText::_('COM_KUNENA_INTEGRATION_'.strtoupper($category->accesstype));
} elseif ($jversion->RELEASE == '1.5') {
if ($category->pub_access == 0) {
$category->pub_group = JText::_('COM_KUNENA_EVERYBODY');
} else if ($category->pub_access == - 1) {
$category->pub_group = JText::_('COM_KUNENA_ALLREGISTERED');
} else if ($category->pub_access == 1) {
$category->pub_group = JText::_('COM_KUNENA_NOBODY');
} else {
$category->pub_group = JText::_( $acl->getGroupName($category->pub_access) );
}
} else {
$category->pub_group = $category->pub_access ? JText::_( $acl->getGroupName($category->pub_access) ) : JText::_('COM_KUNENA_NOBODY');
}
if ($category->accesstype != 'none') {
$category->admin_group = '';
} else {
$category->admin_group = JText::_ ( $acl->getGroupName($category->admin_access ));
}
if ($me->isAdmin($category->id) && $category->isCheckedOut(0)) {
$category->editor = KunenaFactory::getUser($category->checked_out)->getName();
} else {
$category->checked_out = 0;
$category->editor = '';
}
$admin += $me->isAdmin($category->id);
}
$this->setState ( 'list.count.admin', $admin );
}
if (isset($orphans)) {
$app = JFactory::getApplication ();
$app->enqueueMessage ( JText::_ ( 'COM_KUNENA_CATEGORY_ORPHAN_DESC' ), 'notice' );
}
return $this->_admincategories;
}
示例7: displayBreadcrumb
function displayBreadcrumb($tpl = null)
{
if ($this->offline) {
return;
}
$catid = JRequest::getInt('catid', 0);
$id = JRequest::getInt('id', 0);
$view = JRequest::getWord('view', 'default');
$layout = JRequest::getWord('layout', 'default');
$this->breadcrumb = $pathway = $this->app->getPathway();
$active = $this->app->getMenu()->getActive();
if (empty($this->pathway)) {
KunenaFactory::loadLanguage('com_kunena.sys', 'admin');
if ($catid) {
$parents = KunenaForumCategoryHelper::getParents($catid);
$parents[$catid] = KunenaForumCategoryHelper::get($catid);
// Remove categories from pathway if menu item contains/excludes them
if (!empty($active->query['catid']) && isset($parents[$active->query['catid']])) {
$curcatid = $active->query['catid'];
while (($item = array_shift($parents)) !== null) {
if ($item->id == $curcatid) {
break;
}
}
}
foreach ($parents as $parent) {
$pathway->addItem($this->escape($parent->name), KunenaRoute::normalize("index.php?option=com_kunena&view=category&catid={$parent->id}"));
}
}
if ($view == 'announcement') {
$pathway->addItem(JText::_('COM_KUNENA_ANN_ANNOUNCEMENTS'), KunenaRoute::normalize("index.php?option=com_kunena&view=announcement&layout=list"));
} elseif ($id) {
$topic = KunenaForumTopicHelper::get($id);
$pathway->addItem($this->escape($topic->subject), KunenaRoute::normalize("index.php?option=com_kunena&view=category&catid={$catid}&id={$topic->id}"));
}
if ($view == 'topic') {
$active_layout = !empty($active->query['view']) && $active->query['view'] == 'topic' && !empty($active->query['layout']) ? $active->query['layout'] : '';
switch ($layout) {
case 'create':
if ($active_layout != 'create') {
$pathway->addItem($this->escape(JText::_('COM_KUNENA_MENU_TOPIC_CREATE'), KunenaRoute::normalize()));
}
break;
case 'reply':
if ($active_layout != 'reply') {
$pathway->addItem($this->escape(JText::_('COM_KUNENA_MENU_TOPIC_REPLY'), KunenaRoute::normalize()));
}
break;
case 'edit':
if ($active_layout != 'edit') {
$pathway->addItem($this->escape(JText::_('COM_KUNENA_MENU_TOPIC_EDIT'), KunenaRoute::normalize()));
}
break;
}
}
}
$this->pathway = array();
foreach ($pathway->getPathway() as $pitem) {
$item = new StdClass();
$item->name = $this->escape($pitem->name);
$item->link = KunenaRoute::_($pitem->link);
if ($item->link) {
$this->pathway[] = $item;
}
}
$result = $this->loadTemplateFile($tpl, array('pathway' => $this->pathway));
if (JError::isError($result)) {
return $result;
}
echo $result;
}