本文整理汇总了PHP中KunenaProfiler类的典型用法代码示例。如果您正苦于以下问题:PHP KunenaProfiler类的具体用法?PHP KunenaProfiler怎么用?PHP KunenaProfiler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KunenaProfiler类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* @see KunenaControllerBase::execute()
*/
public function execute()
{
KUNENA_PROFILER ? KunenaProfiler::instance()->start('function ' . get_class($this) . '::' . __FUNCTION__ . '()') : null;
try {
// Run before executing action.
$result = $this->before();
if ($result === false) {
KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . get_class($this) . '::' . __FUNCTION__ . '()') : null;
return KunenaLayout::factory('Empty')->setOptions($this->getOptions());
}
// Display layout with given parameters.
$this->output = $this->display();
// Run after executing action.
$this->after();
} catch (KunenaExceptionAuthorise $e) {
if ($this->primary) {
KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . get_class($this) . '::' . __FUNCTION__ . '()') : null;
throw $e;
} else {
$this->output = KunenaLayout::factory('Empty')->setOptions($this->getOptions());
}
}
KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . get_class($this) . '::' . __FUNCTION__ . '()') : null;
return $this->output;
}
开发者ID:anawu2006,项目名称:PeerLearning,代码行数:28,代码来源:display.php
示例2: toTimeAgo
public function toTimeAgo()
{
KUNENA_PROFILER ? KunenaProfiler::instance()->start('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
$chunks = array('y' => array(JText::_('COM_KUNENA_DATE_YEAR'), JText::_('COM_KUNENA_DATE_YEARS')), 'm' => array(JText::_('COM_KUNENA_DATE_MONTH'), JText::_('COM_KUNENA_DATE_MONTHS')), 'w' => array(JText::_('COM_KUNENA_DATE_WEEK'), JText::_('COM_KUNENA_DATE_WEEKS')), 'd' => array(JText::_('COM_KUNENA_DATE_DAY'), JText::_('COM_KUNENA_DATE_DAYS')), 'h' => array(JText::_('COM_KUNENA_DATE_HOUR'), JText::_('COM_KUNENA_DATE_HOURS')), 'i' => array(JText::_('COM_KUNENA_DATE_MINUTE'), JText::_('COM_KUNENA_DATE_MINUTES')));
// we only want to output two chunks of time here, eg: "x years, xx months" or "x days, xx hours"
$tick = 0;
$output = '';
$diff = $this->diff(new JDate());
foreach ($diff as $name => $count) {
if ($name == 'd') {
// Days are special case as we want to break it into weeks and days.
$weeks = (int) ($count / 7);
if ($weeks) {
$count %= 7;
$output .= $weeks == 1 ? " 1 {$chunks['w'][0]}" : " {$weeks} {$chunks['w'][1]}";
if (2 == ++$tick) {
break;
}
}
}
if (!$count || !isset($chunks[$name])) {
continue;
}
$output .= $count == 1 ? " 1 {$chunks[$name][0]}" : " {$count} {$chunks[$name][1]}";
if (2 == ++$tick) {
break;
}
}
if (!$output) {
$output .= '0 ' . JText::_('COM_KUNENA_DATE_MINUTES');
}
$output = JText::sprintf('COM_KUNENA_LIB_TIME_AGO', trim($output));
KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
return $output;
}
开发者ID:sillysachin,项目名称:teamtogether,代码行数:35,代码来源:date.php
示例3: get
/**
* Returns the global KunenaUserHelper object, only creating it if it doesn't already exist.
*
* @access public
* @param int $id The user to load - Can be an integer or string - If string, it is converted to ID automatically.
* @return JUser The User object.
* @since 1.6
*/
public static function get($identifier = null, $reload = false)
{
KUNENA_PROFILER ? KunenaProfiler::instance()->start('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
if ($identifier === null || $identifier === false) {
KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
return self::$_me;
}
if ($identifier instanceof KunenaUser) {
KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
return $identifier;
}
// Find the user id
if ($identifier instanceof JUser) {
$id = intval($identifier->id);
} else {
if (is_numeric($identifier)) {
$id = intval($identifier);
} else {
jimport('joomla.user.helper');
$id = intval(JUserHelper::getUserId((string) $identifier));
}
}
// Always return fresh user if id is anonymous/not found
if ($id === 0) {
KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
return new KunenaUser($id);
} else {
if ($reload || empty(self::$_instances[$id])) {
self::$_instances[$id] = new KunenaUser($id);
}
}
KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
return self::$_instances[$id];
}
开发者ID:laiello,项目名称:senluonirvana,代码行数:42,代码来源:helper.php
示例4: initialize
static public function initialize($name, $integration) {
KUNENA_PROFILER ? KunenaProfiler::instance()->start('function '.__CLASS__.'::'.__FUNCTION__."($name,$integration)") : null;
$object = self::_initialize($name, $integration);
if (!$object) $object = self::_initialize($name, 'auto');
KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function '.__CLASS__.'::'.__FUNCTION__."($name,$integration)") : null;
return $object;
}
开发者ID:GoremanX,项目名称:Kunena-2.0,代码行数:7,代码来源:integration.php
示例5: __construct
public function __construct($config = array())
{
$name = isset($config['name']) ? $config['name'] : $this->getName();
$this->document = JFactory::getDocument();
$this->document->setBase('');
$this->profiler = KunenaProfiler::instance('Kunena');
$this->app = JFactory::getApplication();
$this->me = KunenaUserHelper::getMyself();
$this->config = KunenaFactory::getConfig();
$this->ktemplate = KunenaFactory::getTemplate();
// Set the default template search path
if ($this->app->isSite() && !isset($config['template_path'])) {
$config['template_path'] = $this->ktemplate->getTemplatePaths("html/{$name}", true);
}
if ($this->app->isAdmin()) {
$templateAdmin = KunenaFactory::getAdminTemplate();
$templateAdmin->initialize();
$config['template_path'] = $templateAdmin->getTemplatePaths($name);
}
parent::__construct($config);
if ($this->app->isSite()) {
// Add another template file lookup path specific to the current template
$fallback = JPATH_THEMES . "/{$this->app->getTemplate()}/html/com_kunena/{$this->ktemplate->name}/{$this->getName()}";
$this->addTemplatePath($fallback);
}
// Use our own browser side cache settings.
JResponse::allowCache(false);
JResponse::setHeader('Expires', 'Mon, 1 Jan 2001 00:00:00 GMT', true);
JResponse::setHeader('Last-Modified', gmdate("D, d M Y H:i:s") . ' GMT', true);
JResponse::setHeader('Cache-Control', 'no-store, must-revalidate, post-check=0, pre-check=0', true);
}
开发者ID:proyectoseb,项目名称:University,代码行数:31,代码来源:view.php
示例6: __construct
function __construct($config = array()){
parent::__construct($config);
$this->profiler = KunenaProfiler::instance('Kunena');
$this->me = KunenaUserHelper::getMyself();
$this->config = KunenaFactory::getConfig();
$this->template = KunenaFactory::getTemplate();
}
开发者ID:rich20,项目名称:Kunena,代码行数:7,代码来源:view.php
示例7: getURL
public function getURL($user, $sizex=90, $sizey=90) {
KUNENA_PROFILER ? KunenaProfiler::instance()->start('function '.__CLASS__.'::'.__FUNCTION__.'()') : null;
$size = $this->getSize($sizex, $sizey);
if (!$size->x || !$size->y) return;
$result = $this->_getURL($user, $size->x, $size->y);
KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function '.__CLASS__.'::'.__FUNCTION__.'()') : null;
return $result;
}
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:8,代码来源:avatar.php
示例8: load
public function load($userlist)
{
KUNENA_PROFILER ? KunenaProfiler::instance()->start('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
if (class_exists('CFactory') && method_exists('CFactory', 'loadUsers')) {
CFactory::loadUsers($userlist);
}
KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
}
开发者ID:madcsaba,项目名称:li-de,代码行数:8,代码来源:avatar.php
示例9: getTime
/**
* Method to get the time of page generation
*
* @return string
*/
protected function getTime()
{
$config = KunenaFactory::getConfig();
if (!$config->time_to_create_page) {
return null;
}
$profiler = KunenaProfiler::instance('Kunena');
$time = $profiler->getTime('Total Time');
return sprintf('%0.3f', $time);
}
开发者ID:anawu2006,项目名称:PeerLearning,代码行数:15,代码来源:footer.php
示例10: parseBBCode
public static function parseBBCode($txt, $parent = null, $len = 0)
{
if (!$txt) {
return;
}
KUNENA_PROFILER ? KunenaProfiler::instance()->start('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
$bbcode = KunenaBbcode::getInstance(self::$relative);
$bbcode->parent = $parent;
$bbcode->SetLimit($len);
$bbcode->SetPlainMode(false);
$txt = $bbcode->Parse($txt);
$txt = self::prepareContent($txt);
KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
return $txt;
}
开发者ID:anawu2006,项目名称:PeerLearning,代码行数:15,代码来源:parser.php
示例11: __construct
public function __construct($config = array())
{
$name = isset($config['name']) ? $config['name'] : $this->getName();
$this->document = JFactory::getDocument();
$this->profiler = KunenaProfiler::instance('Kunena');
$this->app = JFactory::getApplication();
$this->me = KunenaUserHelper::getMyself();
$this->config = KunenaFactory::getConfig();
$this->ktemplate = KunenaFactory::getTemplate();
// Set the default template search path
if ($this->app->isSite() && !isset($config['template_path'])) {
$config['template_path'] = $this->ktemplate->getTemplatePaths("html/{$name}", true);
}
parent::__construct($config);
if ($this->app->isSite()) {
// Add another template file lookup path specific to the current template
$fallback = JPATH_THEMES . "/{$this->app->getTemplate()}/html/com_kunena/{$this->ktemplate->name}/{$this->getName()}";
$this->addTemplatePath($fallback);
}
}
开发者ID:laiello,项目名称:senluonirvana,代码行数:20,代码来源:view.php
示例12:
// Display offline message if Kunena hasn't been fully installed.
if (!class_exists('KunenaForum') || !KunenaForum::isCompatible('4.0') || !KunenaForum::installed())
{
$lang = JFactory::getLanguage();
$lang->load('com_kunena.install', JPATH_ADMINISTRATOR . '/components/com_kunena', 'en-GB');
$lang->load('com_kunena.install', JPATH_ADMINISTRATOR . '/components/com_kunena');
JResponse::setHeader('Status', '503 Service Temporarily Unavailable', true);
?>
<h2><?php echo JText::_('COM_KUNENA_INSTALL_OFFLINE_TOPIC') ?></h2>
<div><?php echo JText::_('COM_KUNENA_INSTALL_OFFLINE_DESC') ?></div>
<?php
return;
}
// Display time it took to create the entire page in the footer.
$kunena_profiler = KunenaProfiler::instance('Kunena');
$kunena_profiler->start('Total Time');
KUNENA_PROFILER ? $kunena_profiler->mark('afterLoad') : null;
// Prevent direct access to the component if the option has been disabled.
if (!KunenaConfig::getInstance()->get('access_component', 1))
{
$active = JFactory::getApplication()->getMenu()->getActive();
if (!$active)
{
// Prevent access without using a menu item.
JLog::add("Kunena: Direct access denied: " . JUri::getInstance()->toString(array('path', 'query')), JLog::WARNING, 'kunena');
JError::raiseError(404, JText::_('JLIB_APPLICATION_ERROR_COMPONENT_NOT_FOUND'));
}
elseif ($active->type != 'component' || $active->component != 'com_kunena')
开发者ID:BillVGN,项目名称:PortalPRP,代码行数:31,代码来源:kunena.php
示例13: getLatestTopics
/**
* @param mixed $categories
* @param int $limitstart
* @param int $limit
* @param array $params
*
* @return array|KunenaForumTopic[]
*/
public static function getLatestTopics($categories = false, $limitstart = 0, $limit = 0, $params = array())
{
KUNENA_PROFILER ? KunenaProfiler::instance()->start('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
$db = JFactory::getDBO();
$config = KunenaFactory::getConfig();
if ($limit < 1 && empty($params['nolimit'])) {
$limit = $config->threads_per_page;
}
$reverse = isset($params['reverse']) ? (int) $params['reverse'] : 0;
$orderby = isset($params['orderby']) ? (string) $params['orderby'] : 'tt.last_post_time DESC';
$starttime = isset($params['starttime']) ? (int) $params['starttime'] : 0;
$user = isset($params['user']) ? KunenaUserHelper::get($params['user']) : KunenaUserHelper::getMyself();
$hold = isset($params['hold']) ? (string) $params['hold'] : 0;
$moved = isset($params['moved']) ? (string) $params['moved'] : 0;
$where = isset($params['where']) ? (string) $params['where'] : '';
if (strstr('ut.last_', $orderby)) {
$post_time_field = 'ut.last_post_time';
} elseif (strstr('tt.first_', $orderby)) {
$post_time_field = 'tt.first_post_time';
} else {
$post_time_field = 'tt.last_post_time';
}
$categories = KunenaForumCategoryHelper::getCategories($categories, $reverse);
$catlist = array();
foreach ($categories as $category) {
$catlist += $category->getChannels();
}
if (empty($catlist)) {
KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
return array(0, array());
}
$catlist = implode(',', array_keys($catlist));
$whereuser = array();
if (!empty($params['started'])) {
$whereuser[] = 'ut.owner=1';
}
if (!empty($params['replied'])) {
$whereuser[] = '(ut.owner=0 AND ut.posts>0)';
}
if (!empty($params['posted'])) {
$whereuser[] = 'ut.posts>0';
}
if (!empty($params['favorited'])) {
$whereuser[] = 'ut.favorite=1';
}
if (!empty($params['subscribed'])) {
$whereuser[] = 'ut.subscribed=1';
}
if ($config->keywords || $config->userkeywords) {
$kwids = array();
if (!empty($params['keywords'])) {
$keywords = KunenaKeywordHelper::getByKeywords($params['keywords']);
foreach ($keywords as $keyword) {
$kwids[] = $keyword->id;
}
$kwids = implode(',', $kwids);
}
//TODO: add support for keywords (example:)
/* SELECT tt.*, COUNT(*) AS score FROM #__kunena_keywords_map AS km
INNER JOIN #__kunena_topics` AS tt ON km.topic_id=tt.id
WHERE km.keyword_id IN (1,2) AND km.user_id IN (0,62)
GROUP BY topic_id
ORDER BY score DESC, tt.last_post_time DESC */
}
$wheretime = $starttime ? " AND {$post_time_field}>{$db->Quote($starttime)}" : '';
$whereuser = $whereuser ? " AND ut.user_id={$db->Quote($user->userid)} AND (" . implode(' OR ', $whereuser) . ')' : '';
$where = "tt.hold IN ({$hold}) AND tt.category_id IN ({$catlist}) {$whereuser} {$wheretime} {$where}";
if (!$moved) {
$where .= " AND tt.moved_id='0'";
}
// Get total count
if ($whereuser) {
$query = "SELECT COUNT(*) FROM #__kunena_user_topics AS ut INNER JOIN #__kunena_topics AS tt ON tt.id=ut.topic_id WHERE {$where}";
} else {
$query = "SELECT COUNT(*) FROM #__kunena_topics AS tt WHERE {$where}";
}
$db->setQuery($query);
$total = (int) $db->loadResult();
if (KunenaError::checkDatabaseError() || !$total) {
KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
return array(0, array());
}
// If out of range, use last page
if ($limit && $total < $limitstart) {
$limitstart = intval($total / $limit) * $limit;
}
// Get items
if ($whereuser) {
$query = "SELECT tt.*, ut.posts AS myposts, ut.last_post_id AS my_last_post_id, ut.favorite, tt.last_post_id AS lastread, 0 AS unread\r\n\t\t\t\tFROM #__kunena_user_topics AS ut\r\n\t\t\t\tINNER JOIN #__kunena_topics AS tt ON tt.id=ut.topic_id\r\n\t\t\t\tWHERE {$where} ORDER BY {$orderby}";
} else {
$query = "SELECT tt.*, ut.posts AS myposts, ut.last_post_id AS my_last_post_id, ut.favorite, tt.last_post_id AS lastread, 0 AS unread\r\n\t\t\t\tFROM #__kunena_topics AS tt\r\n\t\t\t\tLEFT JOIN #__kunena_user_topics AS ut ON tt.id=ut.topic_id AND ut.user_id={$db->Quote($user->userid)}\r\n\t\t\t\tWHERE {$where} ORDER BY {$orderby}";
}
//.........这里部分代码省略.........
开发者ID:anawu2006,项目名称:PeerLearning,代码行数:101,代码来源:helper.php
示例14: setItemID
protected static function setItemID($uri) {
static $candidates = array();
KUNENA_PROFILER ? KunenaProfiler::instance()->start('function '.__CLASS__.'::'.__FUNCTION__.'()') : null;
$view = $uri->getVar('view');
$catid = (int) $uri->getVar('catid');
$key = $view.$catid;
if (!isset($candidates[$key])) {
if (self::$search === false) self::build();
$search = array();
if (self::$home) {
// Search from the current home menu
$search[self::$home->id] = 1;
// Then search from all linked home menus
$search += self::$search['home'][self::$home->id];
}
// Finally search from other home menus
$search += self::$search['home'];
// Find all potential candidates
$candidates[$key] = array();
foreach ($search as $id=>$dummy) {
$follow = !empty(self::$menu[$id]) ? self::$menu[$id] : null;
if ($follow && self::checkHome($follow, $catid)) {
$candidates[$key] += !empty(self::$search[$view][$follow->id]) ? self::$search[$view][$follow->id] : array();
if ($view == 'topic') $candidates[$key] += !empty(self::$search['category'][$follow->id]) ? self::$search['category'][$follow->id] : array();
$candidates[$key][$follow->id] = $follow->id;
}
}
// Don't forget lonely candidates
$candidates[$key] += !empty(self::$search[$view][0]) ? self::$search[$view][0] : array();
if ($view == 'topic') $candidates[$key] += !empty(self::$search['category'][0]) ? self::$search['category'][0] : array();
}
$bestid = $bestcount = 0;
//echo "$key "; print_r($candidates[$key]);
foreach ($candidates[$key] as $id) {
$item = self::$menu[$id];
switch ($item->query['view']) {
case 'home':
$matchcount = 1;
break;
case 'category':
case 'topic':
$matchcount = self::checkCategory($item, $uri);
break;
default:
$matchcount = self::check($item, $uri);
}
if ($matchcount > $bestcount) {
// This is our best candidate this far
$bestid = $item->id;
$bestcount = $matchcount;
}
}
$uri->setVar('Itemid', $bestid);
KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function '.__CLASS__.'::'.__FUNCTION__.'()') : null;
return $bestid;
}
开发者ID:rich20,项目名称:Kunena,代码行数:58,代码来源:route.php
示例15: KunenaBuildRoute
/**
* Build SEF URL
*
* All SEF URLs are formatted like this:
*
* http://site.com/menuitem/1-category-name/10-subject/[view]/[layout]/[param1]-value1/[param2]-value2?param3=value3¶m4=value4
*
* - If catid exists, category will always be in the first segment
* - If there is no catid, second segment for message will not be used (param-value: id-10)
* - [view] and [layout] are the only parameters without value
* - all other segments (task, id, userid, page, sel) are using param-value format
*
* NOTE! Only major variables are using SEF segments
*
* @param $query
* @return array Segments
*/
function KunenaBuildRoute(&$query)
{
$segments = array();
// If Kunena Forum isn't installed or SEF is not enabled, do nothing
if (!class_exists('KunenaForum') || !KunenaForum::isCompatible('3.0') || !KunenaForum::installed() || !KunenaRoute::$config->sef) {
return $segments;
}
KUNENA_PROFILER ? KunenaProfiler::instance()->start('function ' . __FUNCTION__ . '()') : null;
// Get menu item
$menuitem = null;
if (isset($query['Itemid'])) {
static $menuitems = array();
$Itemid = $query['Itemid'] = (int) $query['Itemid'];
if (!isset($menuitems[$Itemid])) {
$menuitems[$Itemid] = JFactory::getApplication()->getMenu()->getItem($Itemid);
if (!$menuitems[$Itemid]) {
// Itemid doesn't exist or is invalid
unset($query['Itemid']);
}
}
$menuitem = $menuitems[$Itemid];
}
// Safety check: we need view in order to create SEF URLs
if (!isset($menuitem->query['view']) && empty($query['view'])) {
KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . __FUNCTION__ . '()') : null;
return $segments;
}
// Get view for later use (query wins menu item)
$view = isset($query['view']) ? (string) preg_replace('/[^a-z]/', '', $query['view']) : $menuitem->query['view'];
// Get default values for URI variables
if (isset(KunenaRoute::$views[$view])) {
$defaults = KunenaRoute::$views[$view];
}
// Check all URI variables and remove those which aren't needed
foreach ($query as $var => $value) {
if (isset($defaults[$var]) && !isset($menuitem->query[$var]) && $value == $defaults[$var]) {
// Remove URI variable which has default value
unset($query[$var]);
} elseif (isset($menuitem->query[$var]) && $value == $menuitem->query[$var] && $var != 'Itemid' && $var != 'option') {
// Remove URI variable which has the same value as menu item
unset($query[$var]);
}
}
// We may have catid also in the menu item (it will not be in URI)
$numeric = !empty($menuitem->query['catid']);
// Support URIs like: /forum/12-my_category
if (!empty($query['catid']) && ($view == 'category' || $view == 'topic' || $view == 'home')) {
// TODO: ensure that we have view=category/topic
$catid = (int) $query['catid'];
if ($catid) {
$numeric = true;
$alias = KunenaForumCategoryHelper::get($catid)->alias;
// If category alias is empty, use category id; otherwise use alias
$segments[] = empty($alias) ? $catid : $alias;
// This segment fully defines category view so the variable is no longer needed
if ($view == 'category') {
unset($query['view']);
}
}
unset($query['catid']);
}
// Support URIs like: /forum/12-category/123-topic
if (!empty($query['id']) && $numeric) {
$id = (int) $query['id'];
if ($id) {
$subject = KunenaRoute::stringURLSafe(KunenaForumTopicHelper::get($id)->subject);
if (empty($subject)) {
$segments[] = $id;
} else {
$segments[] = "{$id}-{$subject}";
}
// This segment fully defines topic view so the variable is no longer needed
if ($view == 'topic') {
unset($query['view']);
}
}
unset($query['id']);
} else {
// No id available, do not use numeric variable for mesid
$numeric = false;
}
// View gets added only when we do not use short URI for category/topic
if (!empty($query['view'])) {
//.........这里部分代码省略.........
开发者ID:madcsaba,项目名称:li-de,代码行数:101,代码来源:router.php
示例16: getAllowedCategories
public function getAllowedCategories($user = null, $rule = 'read') {
static $read = array();
KUNENA_PROFILER ? KunenaProfiler::instance()->start('function '.__CLASS__.'::'.__FUNCTION__.'()') : null;
$user = KunenaFactory::getUser($user);
$id = $user->userid;
$allowed = array();
switch ($rule) {
case 'read':
case 'post':
case 'reply':
case 'edit':
if (!isset($read[$id])) {
$app = JFactory::getApplication();
// TODO: handle guests/bots with no userstate
$read[$id] = $app->getUserState("com_kunena.user{$id}_read");
if ($read[$id] === null) {
$read[$id] = array();
$categories = KunenaForumCategoryHelper::getCategories(false, false, 'none');
foreach ( $categories as $category ) {
if (!$category->published) {
unset($categories[$category->id]);
}
if ($id && self::isModerator($id, $category->id)) {
$read[$id][$category->id] = $category->id;
unset($categories[$category->id]);
}
}
$read[$id] += self::$instance->loadAllowedCategories($id, $categories);
$app->setUserState("com_kunena.user{$id}_read", $read[$id]);
}
}
$allowed = $read[$id];
break;
case 'moderate':
if (isset(self::$moderatorsByUserid[$id])) $allowed += self::$moderatorsByUserid[$id];
// Continue: Administrators have also moderation permissions
case 'admin':
if (isset(self::$adminsByUserid[$id])) $allowed += self::$adminsByUserid[$id];
}
KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function '.__CLASS__.'::'.__FUNCTION__.'()') : null;
return $allowed;
}
开发者ID:rich20,项目名称:Kunena,代码行数:45,代码来源:access.php
示例17: authorise
/**
* @param string $action
* @param mixed $user
* @param bool $silent
*
* @return bool
* @deprecated K4.0
*/
public function authorise($action = 'read', $user = null, $silent = false)
{
KUNENA_PROFILER ? KunenaProfiler::instance()->start('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
if ($user === null) {
$user = KunenaUserHelper::getMyself();
} elseif (!$user instanceof KunenaUser) {
$user = KunenaUserHelper::get($user);
}
$exception = $this->tryAuthorise($action, $user, false);
if ($silent === false && $exception) {
$this->setError($exception->getMessage());
}
KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
if ($silent !== null) {
return !$exception;
}
return $exception ? $exception->getMessage() : null;
}
开发者ID:giabmf11,项目名称:Kunena-Forum,代码行数:26,代码来源:topic.php
示例18: stringURLSafe
function stringURLSafe($str) {
static $filtered = array();
KUNENA_PROFILER ? KunenaProfiler::instance()->start('function '.__CLASS__.'::'.__FUNCTION__.'()') : null;
if (!isset($filtered[$str])) {
if (self::$config->sefutf8) {
$str = self::filterOutput ( $str );
$filtered[$str] = urlencode ( $str );
} else {
$filtered[$str] = JFilterOutput::stringURLSafe ( $str );
}
}
KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function '.__CLASS__.'::'.__FUNCTION__.'()') : null;
return $filtered[$str];
}
开发者ID:rich20,项目名称:Kunena,代码行数:14,代码来源:router.php
示例19: getAllowedCategories
/**
* @param mixed $user
*
* @return mixed
*/
public function getAllowedCategories($user = null)
{
static $read = array();
KUNENA_PROFILER ? KunenaProfiler::instance()->start('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
if (!$user instanceof KunenaUser) {
$user = KunenaFactory::getUser($user);
}
if (!isset($read[$user->userid])) {
$id = $user->userid;
$app = JFactory::getApplication();
// TODO: handle guests/bots with no userstate
$read[$id] = $app->getUserState("com_kunena.user{$id}_read");
if ($read[$id] === null) {
$list = array();
$categories = KunenaForumCategoryHelper::getCategories(false, false, 'none');
foreach ($categories as $category) {
// Remove unpublished categories
if ($category->published != 1) {
unset($categories[$category->id]);
}
// Moderators have always access
if (self::isModerator($user, $category->id)) {
$list[$category->id] = $category->id;
unset($categories[$category->id]);
}
}
// Get external authorization
if (!empty($categories)) {
// @var KunenaAccess $access
foreach ($this->accesstypes['all'] as $access) {
if (method_exists($access, 'authoriseCategories')) {
$list += $access->authoriseCategories($id, $categories);
}
}
}
// Clean up and filter the resulting list by using only array keys.
$list = array_keys($list);
Joomla\Utilities\ArrayHelper::toInteger($list);
$read[$id] = array_combine($list, $list);
unset($read[$id][0]);
$app->setUserState("com_kunena.user{$id}_read", $read[$id]);
}
}
KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
return $read[$user->userid];
}
开发者ID:Ruud68,项目名称:Kunena-Forum,代码行数:51,代码来源:access.php
示例20: convert
public static function convert($uri, $showstart = 1)
{
// Make sure that input is JUri to legacy Kunena func=xxx
if (!$uri instanceof JUri) {
return;
}
if ($uri->getVar('option') != 'com_kunena') {
return;
}
KUNENA_PROFILER ? KunenaProfiler::instance()->start('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
if ($uri->getVar('func')) {
$uri->setVar('view', $uri->getVar('func'));
$uri->delVar('func');
}
if (!isset(self::$functions[$uri->getVar('view')])) {
KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
return;
}
$legacy = clone $uri;
// Turn &do=xxx into &layout=xxx
if ($uri->getVar('do')) {
$uri->setVar('layout', $uri->getVar('do'));
$uri->delVar('do');
}
$app = JFactory::getApplication();
$config = KunenaFactory::getConfig();
$changed = false;
switch ($uri->getVar('view')) {
case 'entrypage':
$changed = true;
$uri->setVar('view', 'home');
break;
case 'listcat':
$changed = true;
$uri->setVar('view', 'category');
$uri->setVar('layout', 'list');
break;
case 'showcat':
$changed = true;
$uri->setVar('view', 'category');
$page = (int) $uri->getVar('page', $showstart);
if ($page > 0) {
$uri->setVar('limitstart', (int) $config->messages_per_page * ($page - 1));
$uri->setVar('limit', (int) $config->messages_per_page);
}
$uri->delVar('page');
break;
case 'latest':
case 'mylatest':
case 'noreplies':
case 'subscriptions':
case 'favorites':
case 'userposts':
case 'unapproved':
case 'deleted':
$changed = true;
$uri->setVar('view', 'topics');
// Handle both &func=noreplies and &func=latest&do=noreplies
$mode = $uri->getVar('layout') ? $uri->getVar('layout') : $uri->getVar('view');
switch ($mode) {
case 'latest':
$uri->setVar('layout', 'default');
$uri->setVar('mode', 'replies');
break;
case 'unapproved':
$uri->setVar('layout', 'default');
$uri->setVar('mode', 'unapproved');
break;
case 'deleted':
$uri->setVar('layout', 'default');
$uri->setVar('mode', 'deleted');
break;
case 'noreplies':
$uri->setVar('layout', 'default');
$uri->setVar('mode', 'noreplies');
break;
case 'latesttopics':
$uri->setVar('layout', 'default');
$uri->setVar('mode', 'topics');
break;
case 'mylatest':
$uri->setVar('layout', 'user');
$uri->setVar('mode', 'default');
break;
case 'subscriptions':
$uri->setVar('layout', 'user');
$uri->setVar('mode', 'subscriptions');
break;
case 'favorites':
$uri->setVar('layout', 'user');
$uri->setVar('mode', 'favorites');
break;
case 'owntopics':
$uri->setVar('layout', 'user');
$uri->setVar('mode', 'started');
break;
case 'userposts':
$uri->setVar('userid', '0');
// Continue in latestposts
// Continue in latestposts
//.........这里部分代码省略.........
开发者ID:giabmf11,项目名称:Kunena-Forum,代码行数:101,代码来源:legacy.php
注:本文中的KunenaProfiler类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论