本文整理汇总了PHP中KunenaProfiler类的典型用法代码示例。如果您正苦于以下问题:PHP KunenaProfiler类的具体用法?PHP KunenaProfiler怎么用?PHP KunenaProfiler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KunenaProfiler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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];
}
示例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;
}
示例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);
}
示例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();
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
}
示例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')
示例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}";
}
//.........这里部分代码省略.........
示例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;
}
示例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'])) {
//.........这里部分代码省略.........