本文整理汇总了PHP中JProfiler::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP JProfiler::getInstance方法的具体用法?PHP JProfiler::getInstance怎么用?PHP JProfiler::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JProfiler
的用法示例。
在下文中一共展示了JProfiler::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: plgSh404sefAnalyticsCustomVars
function plgSh404sefAnalyticsCustomVars(&$customVars, $sefConfig)
{
// add custom variable : page creation time
if ($sefConfig->analyticsEnableTimeCollection) {
$profiler =& JProfiler::getInstance('sh404sef_profiler');
$profiler->mark('');
$pageCreationTime = $profiler->getBuffer();
//extract Data
$pageCreationTime = str_replace('sh404sef_profiler : ', '', $pageCreationTime[0]);
$tmp = explode(', ', $pageCreationTime);
// we may have memory report attached
$time = str_replace(' seconds', '', $tmp[0]);
// classify exact time into predefined categories for encoding
$time = Sh404sefHelperAnalytics::classifyTime($time);
// same for memory used
$memory = empty($tmp[1]) ? 0 : sh404sefHelperAnalytics::classifyMemory(str_replace(' MB', '', trim($tmp[1])));
// store results into incoming array
$customVars[SH404SEF_ANALYTICS_TIME_CUSTOM_VAR]->name = 'Page creation time and ram';
$customVars[SH404SEF_ANALYTICS_TIME_CUSTOM_VAR]->value = ($time << 4) + $memory;
}
// add custom variable : user logged in
if ($sefConfig->analyticsEnableUserCollection) {
$user = JFactory::getUser();
$customVars[SH404SEF_ANALYTICS_USER_CUSTOM_VAR]->name = 'Logged-in user';
$userType = empty($user->usertype) ? 'anonymous' : $user->usertype;
$customVars[SH404SEF_ANALYTICS_USER_CUSTOM_VAR]->value = htmlentities($userType, ENT_QUOTES, 'UTF-8');
}
return true;
}
示例2: templates
/**
* Display the template list.
*
* @return void
*/
private function templates()
{
$input = JFactory::getApplication()->input;
$profiling = false;
if ($profiling) {
// jimport('joomla.error.profiler');
$this->profiler = JProfiler::getInstance('EasyCreator');
}
$this->task = $input->get('task');
$this->ecr_project = $input->get('ecr_project');
$this->path = ECRPATH_EXTENSIONTEMPLATES;
$this->file_path = $input->getPath('file_path');
$this->file_name = $input->getPath('file_name');
$this->com_type = $input->get('com_type');
$this->template = $input->get('template');
$this->comTypes = EcrProjectHelper::getProjectTypes();
$cache = JFactory::getCache();
$cache->setCaching(1);
if ($profiling) {
$this->profiler->mark('start get templates');
}
$this->templates = EcrProjectTemplateHelper::getTemplateList();
if ($profiling) {
$this->profiler->mark('end get cached templates');
}
if ($profiling) {
echo '<pre>' . print_r($this->profiler->getBuffer(), true) . '</pre>';
}
$this->setLayout('templates');
}
示例3: _doCheck
public static function _doCheck()
{
jimport('joomla.error.profiler');
// creating the profiler object will start the counter
$profiler = JProfiler::getInstance('sh404sef_analytics_profiler');
// if not set to auto check and not forced to do so
// when user click on "check updates" button
// we don't actually try to get updates info
$sefConfig =& Sh404sefFactory::getConfig();
// check if allowed to auto check, w/o user clicking on button
if (!$sefConfig->autoCheckNewAnalytics && !self::$_options['forced']) {
// prepare a default response object
$response = new stdClass();
$response->status = true;
$response->statusMessage = JText::_('COM_SH404SEF_CLICK_TO_CHECK_ANALYTICS');
$response->note = '';
return $response;
}
// calculate adapted class name
$className = 'Sh404sefAdapterAnalytics' . strtolower($sefConfig->analyticsType);
$handler = new $className();
// ask specialized class to fetch analytics data
$response = $handler->fetchAnalytics($sefConfig, self::$_options);
// done; send response back
return $response;
}
示例4: retrieve
/**
* Retrieve the storage content.
*
* @param string $lang E.g. de-DE, es-ES etc.
* @param string $extension E.g. joomla, com_weblinks, com_easycreator etc.
* @param string $domain Must be 'admin' or 'site'.
*
* @throws G11nException
* @return \g11n\Support\Store
*/
public function retrieve($lang, $extension, $domain = '')
{
if (self::$storage == 'off') {
return false;
}
$profiler = JProfiler::getInstance('LangDebug');
$profiler->mark('start: ' . $extension);
$this->query->clear('where');
$this->query->where('extension = ' . $this->db->quote($extension));
$this->query->where('lang = ' . $this->db->quote($lang));
$this->query->where('scope = ' . $this->db->quote($this->scope));
$this->db->setQuery($this->query);
$e = $this->db->loadObject();
if (empty($e->strings)) {
$profiler->mark('<span style="color: red;">langload db failed ****</span>' . $this->query);
$this->setError($this->db->getError());
return false;
}
$strings = json_decode($e->strings, true);
$profiler->mark('<span style="color: green;">*Loaded db*</span>');
$this->strings = array_merge($this->strings, $strings);
// Language overrides
$this->strings = array_merge($this->strings, $this->override);
$this->paths[$extension][$fileName] = true;
return true;
}
示例5: __construct
public function __construct($context)
{
$this->context = $context;
if (JvrelInit::getCfg('debug')) {
$this->profiler = JProfiler::getInstance('Application');
}
$this->eopsob = new JvrelativesEopsob();
}
示例6: postflight
/**
* Called after any type of action
*
* @param string $route Which action is happening (install|uninstall|discover_install)
* @param jadapterinstance $adapter The object responsible for running this script
*
* @return boolean True on success
*/
public function postflight($route, JAdapterInstance $adapter)
{
if (JDEBUG) {
JProfiler::getInstance('Application')->mark('after' . ucfirst($route) . 'Projectfork');
$buffer = JProfiler::getInstance('Application')->getBuffer();
$app = JFactory::getApplication();
foreach ($buffer as $mark) {
$app->enqueueMessage($mark, 'debug');
}
}
return true;
}
示例7: __destruct
/**
* Adds application response time and memory usage to Chrome Inspector with ChromeLogger extension
*
* See: https://chrome.google.com/webstore/detail/chrome-logger/noaneddfkdjfnfdakjjmocngnfkfehhd
*/
public function __destruct()
{
if (JDEBUG && !headers_sent()) {
$buffer = JProfiler::getInstance('Application')->getBuffer();
if ($buffer) {
$data = strip_tags(end($buffer));
$row = array(array($data), null, 'info');
$header = array('version' => '4.1.0', 'columns' => array('log', 'backtrace', 'type'), 'rows' => array($row));
header('X-ChromeLogger-Data: ' . base64_encode(utf8_encode(json_encode($header))));
}
}
}
示例8: getApplication
/**
* Returns a Joomla application with a root user logged in
*
* @param string $base Base path for the Joomla installation
* @param int $client_id Application client id to spoof. Defaults to admin.
*
* @return Application
*/
public static function getApplication($base, $client_id = self::ADMIN)
{
$_SERVER['SERVER_PORT'] = 80;
if (!self::$_application) {
self::bootstrap($base);
$options = array('root_user' => 'root', 'client_id' => $client_id);
self::$_application = new Application($options);
$credentials = array('name' => 'root', 'username' => 'root', 'groups' => array(8), 'email' => 'root@localhost.home');
self::$_application->authenticate($credentials);
// If there are no marks in JProfiler debug plugin performs a division by zero using count($marks)
\JProfiler::getInstance('Application')->mark('Hello world');
}
return self::$_application;
}
示例9: __construct
/**
* @param Application $app
*/
public function __construct($app)
{
parent::__construct($app);
return;
// for debug only
if (self::$_jbdump === null) {
// Joomla standart profiler
if (JDEBUG) {
self::$_jbdump = JProfiler::getInstance('Application');
}
// jbdump plugin
if (class_exists('jbdump')) {
self::$_jbdump = JBDump::i($this->_jbdumpParams);
}
}
}
示例10: store
/**
* Stores the strings into a storage.
*
* @param string $lang E.g. de-DE, es-ES etc.
* @param string $extension E.g. joomla, com_weblinks, com_easycreator etc.
* @param string $domain Must be 'admin' or 'site'.
*
* @throws G11nException
* @return boolean
*/
public function store($lang, $extension, $domain = '')
{
if (self::$storage == 'off') {
return false;
}
$profiler = JProfiler::getInstance('LangDebug');
$profiler->mark('store: ' . $extension);
// # $fileNames = JFolder::files(JPATH_ADMINISTRATOR, '.sys.ini', false, true);
$strings = self::parseFile($fileName);
$path = self::$cacheDir . '/' . $lang . '.' . $extension . '.txt';
$jsonString = json_encode($strings);
if (!JFile::write($path, $jsonString)) {
throw new G11nException('Unable to write language storage file');
}
$profiler->mark('<span style="color: blue;">wrote file</span>: ' . str_replace(JPATH_ROOT, 'J', $path));
$profiler->mark('store SUCCESS ++++: ' . $extension);
return true;
}
示例11: getApplication
/**
* Returns a Joomla application with a root user logged in
*
* @param string $base Base path for the Joomla installation
* @return Application
*/
public static function getApplication($base)
{
$_SERVER['SERVER_PORT'] = 80;
if (!defined('_JEXEC')) {
$_SERVER['HTTP_HOST'] = 'localhost';
$_SERVER['HTTP_USER_AGENT'] = 'joomla-cli/1.0.0';
define('_JEXEC', 1);
define('DS', DIRECTORY_SEPARATOR);
define('JPATH_BASE', realpath($base));
require_once JPATH_BASE . '/includes/defines.php';
require_once JPATH_BASE . '/includes/framework.php';
require_once JPATH_LIBRARIES . '/import.php';
require_once JPATH_LIBRARIES . '/cms.php';
}
$credentials = array('name' => 'root', 'username' => 'root', 'groups' => array(8), 'email' => 'root@localhost.home');
$application = new Application(array('root_user' => 'root'));
$application->authenticate($credentials);
// If there are no marks in JProfiler debug plugin performs a division by zero using count($marks)
\JProfiler::getInstance('Application')->mark('Hello world');
return $application;
}
示例12: onAfterInitialise
/**
* Converting the site URL to fit to the HTTP request.
*
* @return void
*
* @since 1.5
*/
public function onAfterInitialise()
{
$app = JFactory::getApplication();
$user = JFactory::getUser();
if ($app->isAdmin()) {
return;
}
if (count($app->getMessageQueue())) {
return;
}
if ($user->get('guest') && $app->input->getMethod() == 'GET') {
$this->_cache->setCaching(true);
}
$data = $this->_cache->get($this->_cache_key);
if ($data !== false) {
// Set cached body.
$app->setBody($data);
echo $app->toString();
if (JDEBUG) {
JProfiler::getInstance('Application')->mark('afterCache');
}
$app->close();
}
}
示例13: renderModule
/**
* Render the module.
*
* @param object $module A module object.
* @param array $attribs An array of attributes for the module (probably from the XML).
*
* @return string The HTML content of the module output.
*
* @since 11.1
*/
public static function renderModule($module, $attribs = array())
{
static $chrome;
if (constant('JDEBUG')) {
JProfiler::getInstance('Application')->mark('beforeRenderModule ' . $module->module . ' (' . $module->title . ')');
}
$app = JFactory::getApplication();
// Record the scope.
$scope = $app->scope;
// Set scope to component name
$app->scope = $module->module;
// Get module parameters
$params = new JRegistry();
$params->loadString($module->params);
// Get module path
$module->module = preg_replace('/[^A-Z0-9_\\.-]/i', '', $module->module);
$path = JPATH_BASE . '/modules/' . $module->module . '/' . $module->module . '.php';
// Load the module
if (file_exists($path)) {
$lang = JFactory::getLanguage();
// 1.5 or Core then 1.6 3PD
$lang->load($module->module, JPATH_BASE, null, false, false) || $lang->load($module->module, dirname($path), null, false, false) || $lang->load($module->module, JPATH_BASE, $lang->getDefault(), false, false) || $lang->load($module->module, dirname($path), $lang->getDefault(), false, false);
$content = '';
ob_start();
include $path;
$module->content = ob_get_contents() . $content;
ob_end_clean();
}
// Load the module chrome functions
if (!$chrome) {
$chrome = array();
}
include_once JPATH_THEMES . '/system/html/modules.php';
$chromePath = JPATH_THEMES . '/' . $app->getTemplate() . '/html/modules.php';
if (!isset($chrome[$chromePath])) {
if (file_exists($chromePath)) {
include_once $chromePath;
}
$chrome[$chromePath] = true;
}
// Make sure a style is set
if (!isset($attribs['style'])) {
$attribs['style'] = 'none';
}
// Dynamically add outline style
if ($app->input->getBool('tp') && JComponentHelper::getParams('com_templates')->get('template_positions_display')) {
$attribs['style'] .= ' outline';
}
foreach (explode(' ', $attribs['style']) as $style) {
$chromeMethod = 'modChrome_' . $style;
// Apply chrome and render module
if (function_exists($chromeMethod)) {
$module->style = $attribs['style'];
ob_start();
$chromeMethod($module, $params, $attribs);
$module->content = ob_get_contents();
ob_end_clean();
}
}
// Revert the scope
$app->scope = $scope;
if (constant('JDEBUG')) {
JProfiler::getInstance('Application')->mark('afterRenderModule ' . $module->module . ' (' . $module->title . ')');
}
return $module->content;
}
示例14: __construct
/**
* Class constructor.
*
* @param mixed $input An optional argument to provide dependency injection for the application's
* input object. If the argument is a JInput object that object will become
* the application's input object, otherwise a default input object is created.
* @param mixed $config An optional argument to provide dependency injection for the application's
* config object. If the argument is a JRegistry object that object will become
* the application's config object, otherwise a default config object is created.
* @param mixed $client An optional argument to provide dependency injection for the application's
* client object. If the argument is a JApplicationWebClient object that object will become
* the application's client object, otherwise a default client object is created.
*
* @since 3.2
*/
public function __construct(JInput $input = null, JRegistry $config = null, JApplicationWebClient $client = null)
{
parent::__construct($input, $config, $client);
// Load and set the dispatcher
$this->loadDispatcher();
// If JDEBUG is defined, load the profiler instance
if (defined('JDEBUG') && JDEBUG) {
$this->profiler = JProfiler::getInstance('Application');
}
// Enable sessions by default.
if (is_null($this->config->get('session'))) {
$this->config->set('session', true);
}
// Set the session default name.
if (is_null($this->config->get('session_name'))) {
$this->config->set('session_name', $this->getName());
}
}
示例15: define
/**
* NOTE: This file should remain compatible with PHP 5.2 to allow us to run our PHP minimum check and show a friendly error message
*/
/**
* Define the application's minimum supported PHP version as a constant so it can be referenced within the application.
*/
define('JOOMLA_MINIMUM_PHP', '5.5.9');
if (version_compare(PHP_VERSION, JOOMLA_MINIMUM_PHP, '<')) {
die('Your host needs to use PHP ' . JOOMLA_MINIMUM_PHP . ' or higher to run this version of Joomla!');
}
// Saves the start time and memory usage.
$startTime = microtime(1);
$startMem = memory_get_usage();
/**
* Constant that is checked in included files to prevent direct access.
*/
define('_JEXEC', 1);
if (file_exists(__DIR__ . '/defines.php')) {
include_once __DIR__ . '/defines.php';
}
if (!defined('_JDEFINES')) {
define('JPATH_BASE', __DIR__);
require_once JPATH_BASE . '/includes/defines.php';
}
require_once JPATH_BASE . '/includes/framework.php';
// Set profiler start time and memory usage and mark afterLoad in the profiler.
JDEBUG ? JProfiler::getInstance('Application')->setStart($startTime, $startMem)->mark('afterLoad') : null;
// Instantiate the application.
$app = JFactory::getApplication('administrator');
// Execute the application.
$app->execute();