本文整理汇总了PHP中KunenaConfig类的典型用法代码示例。如果您正苦于以下问题:PHP KunenaConfig类的具体用法?PHP KunenaConfig怎么用?PHP KunenaConfig使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KunenaConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor.
*/
public function __construct()
{
parent::__construct();
$this->config = KunenaConfig::getInstance();
$this->limit = $this->config->userlist_rows;
$this->query->leftJoin('#__kunena_users AS ku ON ku.userid=a.id');
}
示例2: before
/**
* Load user list.
*
* @throws KunenaExceptionAuthorise
*/
protected function before()
{
parent::before();
$config = KunenaConfig::getInstance();
if ($config->userlist_allowed && JFactory::getUser()->guest) {
throw new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), '401');
}
require_once KPATH_SITE . '/models/user.php';
$this->model = new KunenaModelUser(array(), $this->input);
$this->model->initialize($this->getOptions(), $this->getOptions()->get('embedded', false));
$this->state = $this->model->getState();
$this->me = KunenaUserHelper::getMyself();
$this->config = KunenaConfig::getInstance();
$start = $this->state->get('list.start');
$limit = $this->state->get('list.limit');
// Get list of super admins to exclude or not in filter by configuration.
$filter = JAccess::getUsersByGroup(8);
$finder = new KunenaUserFinder();
$finder->filterByConfiguration($filter)->filterByName($this->state->get('list.search'));
$this->total = $finder->count();
$this->pagination = new KunenaPagination($this->total, $start, $limit);
$alias = 'ku';
$aliasList = array('id', 'name', 'username', 'email', 'block', 'registerDate', 'lastvisitDate');
if (in_array($this->state->get('list.ordering'), $aliasList)) {
$alias = 'a';
}
$this->users = $finder->order($this->state->get('list.ordering'), $this->state->get('list.direction') == 'asc' ? 1 : -1, $alias)->start($this->pagination->limitstart)->limit($this->pagination->limit)->find();
}
示例3: before
/**
* Prepare announcement box display.
*
* @return bool
*/
protected function before()
{
parent::before();
$config = KunenaConfig::getInstance();
if (!$config->showannouncement)
{
return false;
}
$items = KunenaForumAnnouncementHelper::getAnnouncements();
$this->announcement = array_pop($items);
if (!$this->announcement || !$this->announcement->authorise('read'))
{
return false;
}
$view = $this->input->getWord('view', 'default');
$layout = $this->input->getWord('layout', 'default');
if ($view == 'topic' && $layout != 'default' || $view == 'user' || $view == 'search' || $view == 'announcement' && $layout == 'default') {
return false;
}
return true;
}
示例4: __construct
/**
* Method to instantiate the layout.
*
* @param string $name
* @param array $paths The paths queue.
*/
public function __construct($name, array $paths = null)
{
// Setup dependencies.
$this->_name = $name;
$this->includePaths = isset($paths) ? $paths : $this->loadPaths();
$this->debug = JDEBUG || KunenaConfig::getInstance()->get('debug');
}
示例5: initialize
/**
* Initialize class.
*/
static public function initialize()
{
KUNENA_PROFILER ? KunenaProfiler::instance()->start('function '.__CLASS__.'::'.__FUNCTION__.'()') : null;
if (KunenaConfig::getInstance()->get('cache_cat'))
{
// FIXME: Experimental caching.
/** @var JCache|JCacheControllerCallback $cache */
$cache = JFactory::getCache('com_kunena', 'callback');
$cache->setLifeTime(180);
self::$_instances = $cache->call(array('KunenaForumCategoryHelper', 'loadCategories'));
}
else
{
self::$_instances = self::loadCategories();
}
if (is_null(self::$_tree))
{
self::buildTree(self::$_instances);
}
self::$allowed = KunenaAccess::getInstance()->getAllowedCategories();
KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function '.__CLASS__.'::'.__FUNCTION__.'()') : null;
}
示例6: before
/**
* Executed before display.
*/
protected function before()
{
$this->layout = $this->input->getCmd('layout', 'default');
$this->config = KunenaConfig::getInstance();
if ($this->primary) {
$this->document = JFactory::getDocument();
}
}
示例7: before
/**
* Prepare AJAX display.
*
* @return void
*/
protected function before()
{
// Load language files.
KunenaFactory::loadLanguage('com_kunena.sys', 'admin');
KunenaFactory::loadLanguage('com_kunena.templates');
KunenaFactory::loadLanguage('com_kunena.models');
KunenaFactory::loadLanguage('com_kunena.views');
$this->me = KunenaUserHelper::getMyself();
$this->config = KunenaConfig::getInstance();
$this->document = JFactory::getDocument();
$this->template = KunenaFactory::getTemplate();
$this->template->initialize();
}
示例8: before
/**
* Prepare statistics box display.
*
* @return boolean
*/
protected function before()
{
parent::before();
$this->config = KunenaConfig::getInstance();
if (!$this->config->get('showstats') || !$this->config->statslink_allowed && !KunenaUserHelper::get()->exists()) {
throw new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), '404');
}
$statistics = KunenaForumStatistics::getInstance();
$statistics->loadGeneral();
$this->setProperties($statistics);
$this->latestMemberLink = KunenaFactory::getUser(intval($this->lastUserId))->getLink();
$this->statisticsUrl = KunenaFactory::getProfile()->getStatisticsURL();
return true;
}
示例9: before
/**
* Prepare general statistics display.
*
* @return void
*
* @throws KunenaExceptionAuthorise
*/
protected function before()
{
parent::before();
$this->config = KunenaConfig::getInstance();
if (!$this->config->get('showstats')) {
throw new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), '404');
}
if (!$this->config->statslink_allowed && JFactory::getUser()->guest) {
throw new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), '401');
}
$statistics = KunenaForumStatistics::getInstance();
$statistics->loadAll();
$this->setProperties($statistics);
$this->latestMemberLink = KunenaFactory::getUser((int) $this->lastUserId)->getLink();
$this->userlistUrl = KunenaFactory::getProfile()->getUserListUrl();
}
示例10: before
/**
* Prepare Who is online display.
*
* @return void
*
* @throws KunenaExceptionAuthorise
*/
protected function before()
{
parent::before();
$this->config = KunenaConfig::getInstance();
if (!$this->config->get('showwhoisonline')) {
throw new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), '404');
}
$me = KunenaUserHelper::getMyself();
$moderator = intval($me->isModerator()) + intval($me->isAdmin());
$users = KunenaUserHelper::getOnlineUsers();
KunenaUserHelper::loadUsers(array_keys($users));
$onlineusers = KunenaUserHelper::getOnlineCount();
$who = '<strong>' . $onlineusers['user'] . ' </strong>';
if ($onlineusers['user'] == 1) {
$who .= JText::_('COM_KUNENA_WHO_ONLINE_MEMBER') . ' ';
} else {
$who .= JText::_('COM_KUNENA_WHO_ONLINE_MEMBERS') . ' ';
}
$who .= JText::_('COM_KUNENA_WHO_AND');
$who .= '<strong> ' . $onlineusers['guest'] . ' </strong>';
if ($onlineusers['guest'] == 1) {
$who .= JText::_('COM_KUNENA_WHO_ONLINE_GUEST') . ' ';
} else {
$who .= JText::_('COM_KUNENA_WHO_ONLINE_GUESTS') . ' ';
}
$who .= JText::_('COM_KUNENA_WHO_ONLINE_NOW');
$this->membersOnline = $who;
$this->onlineList = array();
$this->hiddenList = array();
foreach ($users as $userid => $usertime) {
$user = KunenaUserHelper::get($userid);
if (!$user->showOnline) {
if ($moderator) {
$this->hiddenList[$user->getName()] = $user;
}
} else {
$this->onlineList[$user->getName()] = $user;
}
}
ksort($this->onlineList);
ksort($this->hiddenList);
$profile = KunenaFactory::getProfile();
$this->usersUrl = $profile->getUserListURL();
}
示例11: checkFileSize
/**
* Check if filesize on file which on going to be uploaded doesn't exceed the limits set by Kunena configuration and Php configuration
*
* @param int $filesize The size of file in bytes
* @param boolean $avatar If the file is an avatar
*
* @return boolean
*/
protected function checkFileSize($filesize, $avatar)
{
if (!$avatar) {
if ($filesize > $this->getMaxSize()) {
return false;
}
} else {
if ($avatar && $filesize > intval(KunenaConfig::getInstance()->avatarsize) * 1024) {
return false;
}
}
return true;
}
示例12: getConfig
/**
* Get a Kunena configuration object
*
* Returns the global {@link KunenaConfig} object, only creating it if it doesn't already exist.
*
* @return KunenaConfig
*/
public static function getConfig() {
return KunenaConfig::getInstance();
}
示例13: build
protected static function build()
{
KUNENA_PROFILER ? KunenaProfiler::instance()->start('function '.__CLASS__.'::'.__FUNCTION__.'()') : null;
if (self::$search === false)
{
$user = KunenaUserHelper::getMyself();
$language = strtolower(JFactory::getDocument()->getLanguage());
self::$search = false;
if (KunenaConfig::getInstance()->get('cache_mid'))
{
// FIXME: Experimental caching.
$cache = self::getCache();
self::$search = unserialize($cache->get('search', "com_kunena.route.v1.{$language}.{$user->userid}"));
}
if (self::$search === false)
{
self::$search['home'] = array();
foreach (self::$menu as $item)
{
// Skip menu items that aren't pointing to Kunena or are using wrong language.
if (($item->component != 'com_kunena' && $item->type != 'alias')
|| ($item->language != '*' && strtolower($item->language) != $language))
{
continue;
}
// Follow links.
if ($item->type == 'alias')
{
if (empty($item->query['Itemid']) || empty(self::$menu[$item->query['Itemid']]))
{
continue;
}
$item = self::$menu[$item->query['Itemid']];
if ($item->component != 'com_kunena' || ($item->language != '*' && strtolower($item->language) != $language))
{
continue;
}
}
// Ignore legacy menu items without view in it.
if (!isset($item->query['view']))
{
continue;
}
// Save Kunena menu items so that we can make fast searches
$home = self::getHome($item);
self::$search[$item->query['view']][$home ? $home->id : 0][$item->id] = $item->id;
}
if (isset($cache))
{
$cache->store(serialize(self::$search), 'search', "com_kunena.route.v1.{$language}.{$user->userid}");
}
}
}
KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function '.__CLASS__.'::'.__FUNCTION__.'()') : null;
}
示例14: getAvailableFilename
/**
* Find filename which isn't already taken in the filesystem.
*
* @param string $folder Relative path from JPATH_ROOT.
* @param string $basename Filename without extension.
* @param string $extension File extension.
* @param bool $protected True to randomize the filename. If not given, uses Kunena configuration setting.
*
* @return string
*
* @since K4.0
*/
public static function getAvailableFilename($folder, $basename, $extension, $protected = null)
{
if (is_null($protected)) {
$protected = (bool) KunenaConfig::getInstance()->attachment_protection;
}
if ($protected) {
// Ignore proposed filename and return totally random and unique name without file extension.
do {
$name = md5(rand());
} while (file_exists(JPATH_ROOT . "/{$folder}/{$name}"));
return $name;
}
// Lets find out if we need to rename the filename.
$basename = preg_replace('/[[:space:]]/', '', KunenaFile::makeSafe($basename));
$extension = trim($extension, '.');
if (empty($basename)) {
$basename = 'file_' . substr(md5(rand()), 2, 7);
}
$newName = "{$basename}.{$extension}";
$date = date('Y-m-d');
// Rename file if there is already one with the same name
if (file_exists(JPATH_ROOT . "/{$folder}/{$newName}")) {
$newName = "{$basename}_{$date}.{$extension}";
for ($i = 2; file_exists(JPATH_ROOT . "/{$folder}/{$newName}"); $i++) {
$newName = "{$basename}_{$date}-{$i}.{$extension}";
}
}
return $newName;
}
示例15: getList
/**
* Get a list of the menu items (taken from Joomla 2.5.1).
* This only method need to be used only in frontend part
*
* @param JRegistry $params The module options.
*
* @return array
* @see modules/mod_menu/helper.php
*/
public static function getList(&$params)
{
$app = JFactory::getApplication();
$menu = $app->getMenu();
// If no active menu, use default
$active = $menu->getActive() ? $menu->getActive() : $menu->getDefault();
$items = false;
// FIXME: Experimental caching.
if (KunenaConfig::getInstance()->get('cache_menu')) {
$levels = JFactory::getUser()->getAuthorisedViewLevels();
asort($levels);
$key = 'menu_items' . $params . implode(',', $levels) . '.' . $active->id;
$cache = JFactory::getCache('com_kunena.menu', '');
$items = $cache->get($key);
}
if ($items === false) {
// Initialise variables.
$path = $active->tree;
$start = (int) $params->get('startLevel');
$end = (int) $params->get('endLevel');
$showAll = $params->get('showAllChildren');
$items = $menu->getItems('menutype', $params->get('menutype'));
if ($items) {
foreach ($items as $i => $item) {
if ($start && $start > $item->level || $end && $item->level > $end || !$showAll && $item->level > 1 && !in_array($item->parent_id, $path) || $start > 1 && !in_array($item->tree[$start - 2], $path)) {
unset($items[$i]);
continue;
}
$item->deeper = false;
$item->shallower = false;
$item->level_diff = 0;
if (isset($lastitem)) {
$lastitem->deeper = $item->level > $lastitem->level;
$lastitem->shallower = $item->level < $lastitem->level;
$lastitem->level_diff = $lastitem->level - $item->level;
}
$item->parent = (bool) $menu->getItems('parent_id', (int) $item->id, true);
$lastitem = $item;
$item->active = false;
$item->flink = $item->link;
switch ($item->type) {
case 'separator':
// No further action needed.
continue;
case 'url':
if (strpos($item->link, 'index.php?') === 0 && strpos($item->link, 'Itemid=') === false) {
// If this is an internal Joomla link, ensure the Itemid is set.
$item->flink = $item->link . '&Itemid=' . $item->id;
}
break;
case 'alias':
// If this is an alias use the item id stored in the parameters to make the link.
$item->flink = 'index.php?Itemid=' . $item->params->get('aliasoptions');
break;
default:
$router = $app::getRouter();
if ($router->getMode() == JROUTER_MODE_SEF) {
$item->flink = 'index.php?Itemid=' . $item->id;
} else {
$item->flink .= '&Itemid=' . $item->id;
}
break;
}
if (strcasecmp(substr($item->flink, 0, 4), 'http') && strpos($item->flink, 'index.php?') !== false) {
$item->flink = JRoute::_($item->flink, false, $item->params->get('secure'));
} else {
$item->flink = JRoute::_($item->flink, false);
}
$item->title = htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8');
$item->anchor_css = htmlspecialchars($item->params->get('menu-anchor_css', ''), ENT_COMPAT, 'UTF-8');
$item->anchor_title = htmlspecialchars($item->params->get('menu-anchor_title', ''), ENT_COMPAT, 'UTF-8');
$item->menu_image = $item->params->get('menu_image', '') ? htmlspecialchars($item->params->get('menu_image', ''), ENT_COMPAT, 'UTF-8') : '';
}
if (isset($lastitem)) {
$lastitem->deeper = ($start ? $start : 1) > $lastitem->level;
$lastitem->shallower = ($start ? $start : 1) < $lastitem->level;
$lastitem->level_diff = $lastitem->level - ($start ? $start : 1);
}
}
if (isset($cache)) {
$cache->store($items, $key);
}
}
return $items;
}