本文整理汇总了PHP中profiling_is_running函数的典型用法代码示例。如果您正苦于以下问题:PHP profiling_is_running函数的具体用法?PHP profiling_is_running怎么用?PHP profiling_is_running使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了profiling_is_running函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: standard_footer_html
/**
* The standard tags (typically performance information and validation links,
* if we are in developer debug mode) that should be output in the footer area
* of the page. Designed to be called in theme layout.php files.
*
* @return string HTML fragment.
*/
public function standard_footer_html() {
global $CFG, $SCRIPT;
if (during_initial_install()) {
// Debugging info can not work before install is finished,
// in any case we do not want any links during installation!
return '';
}
// This function is normally called from a layout.php file in {@link core_renderer::header()}
// but some of the content won't be known until later, so we return a placeholder
// for now. This will be replaced with the real content in {@link core_renderer::footer()}.
$output = $this->unique_performance_info_token;
if ($this->page->devicetypeinuse == 'legacy') {
// The legacy theme is in use print the notification
$output .= html_writer::tag('div', get_string('legacythemeinuse'), array('class'=>'legacythemeinuse'));
}
// Get links to switch device types (only shown for users not on a default device)
$output .= $this->theme_switch_links();
if (!empty($CFG->debugpageinfo)) {
$output .= '<div class="performanceinfo pageinfo">This page is: ' . $this->page->debug_summary() . '</div>';
}
if (debugging(null, DEBUG_DEVELOPER) and has_capability('moodle/site:config', context_system::instance())) { // Only in developer mode
// Add link to profiling report if necessary
if (function_exists('profiling_is_running') && profiling_is_running()) {
$txt = get_string('profiledscript', 'admin');
$title = get_string('profiledscriptview', 'admin');
$url = $CFG->wwwroot . '/admin/tool/profiling/index.php?script=' . urlencode($SCRIPT);
$link= '<a title="' . $title . '" href="' . $url . '">' . $txt . '</a>';
$output .= '<div class="profilingfooter">' . $link . '</div>';
}
$purgeurl = new moodle_url('/admin/purgecaches.php', array('confirm' => 1,
'sesskey' => sesskey(), 'returnurl' => $this->page->url->out_as_local_url(false)));
$output .= '<div class="purgecaches">' .
html_writer::link($purgeurl, get_string('purgecaches', 'admin')) . '</div>';
}
if (!empty($CFG->debugvalidators)) {
// NOTE: this is not a nice hack, $PAGE->url is not always accurate and $FULLME neither, it is not a bug if it fails. --skodak
$output .= '<div class="validators"><ul>
<li><a href="http://validator.w3.org/check?verbose=1&ss=1&uri=' . urlencode(qualified_me()) . '">Validate HTML</a></li>
<li><a href="http://www.contentquality.com/mynewtester/cynthia.exe?rptmode=-1&url1=' . urlencode(qualified_me()) . '">Section 508 Check</a></li>
<li><a href="http://www.contentquality.com/mynewtester/cynthia.exe?rptmode=0&warnp2n3e=1&url1=' . urlencode(qualified_me()) . '">WCAG 1 (2,3) Check</a></li>
</ul></div>';
}
return $output;
}
示例2: standard_footer_html
/**
* The standard tags (typically performance information and validation links,
* if we are in developer debug mode) that should be output in the footer area
* of the page. Designed to be called in theme layout.php files.
* @return string HTML fragment.
*/
public function standard_footer_html()
{
global $CFG, $SCRIPT;
// This function is normally called from a layout.php file in {@link header()}
// but some of the content won't be known until later, so we return a placeholder
// for now. This will be replaced with the real content in {@link footer()}.
$output = self::PERFORMANCE_INFO_TOKEN;
if ($this->page->legacythemeinuse) {
// The legacy theme is in use print the notification
$output .= html_writer::tag('div', get_string('legacythemeinuse'), array('class' => 'legacythemeinuse'));
}
if (!empty($CFG->debugpageinfo)) {
$output .= '<div class="performanceinfo pageinfo">This page is: ' . $this->page->debug_summary() . '</div>';
}
if (debugging(null, DEBUG_DEVELOPER) and has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
// Only in developer mode
// Add link to profiling report if necessary
if (function_exists('profiling_is_running') && profiling_is_running()) {
$txt = get_string('profiledscript', 'admin');
$title = get_string('profiledscriptview', 'admin');
$url = $CFG->wwwroot . '/admin/report/profiling/index.php?script=' . urlencode($SCRIPT);
$link = '<a title="' . $title . '" href="' . $url . '">' . $txt . '</a>';
$output .= '<div class="profilingfooter">' . $link . '</div>';
}
$output .= '<div class="purgecaches"><a href="' . $CFG->wwwroot . '/admin/purgecaches.php?confirm=1&sesskey=' . sesskey() . '">' . get_string('purgecaches', 'admin') . '</a></div>';
}
if (!empty($CFG->debugvalidators)) {
$output .= '<div class="validators"><ul>
<li><a href="http://validator.w3.org/check?verbose=1&ss=1&uri=' . urlencode(qualified_me()) . '">Validate HTML</a></li>
<li><a href="http://www.contentquality.com/mynewtester/cynthia.exe?rptmode=-1&url1=' . urlencode(qualified_me()) . '">Section 508 Check</a></li>
<li><a href="http://www.contentquality.com/mynewtester/cynthia.exe?rptmode=0&warnp2n3e=1&url1=' . urlencode(qualified_me()) . '">WCAG 1 (2,3) Check</a></li>
</ul></div>';
}
if (!empty($CFG->additionalhtmlfooter)) {
$output .= "\n" . $CFG->additionalhtmlfooter;
}
return $output;
}
示例3: shutdown_handler
/**
* @private - do NOT call directly.
*/
public static function shutdown_handler()
{
global $DB;
// Custom stuff first.
foreach (self::$callbacks as $data) {
list($callback, $params) = $data;
try {
if (!is_callable($callback)) {
error_log('Invalid custom shutdown function detected ' . var_export($callback, true));
continue;
}
if ($params === null) {
call_user_func($callback);
} else {
call_user_func_array($callback, $params);
}
} catch (Exception $e) {
error_log('Exception ignored in shutdown function ' . var_export($callback, true) . ':' . $e->getMessage());
}
}
// Handle DB transactions, session need to be written afterwards
// in order to maintain consistency in all session handlers.
if ($DB->is_transaction_started()) {
if (!defined('PHPUNIT_TEST') or !PHPUNIT_TEST) {
// This should not happen, it usually indicates wrong catching of exceptions,
// because all transactions should be finished manually or in default exception handler.
$backtrace = $DB->get_transaction_start_backtrace();
error_log('Potential coding error - active database transaction detected during request shutdown:' . "\n" . format_backtrace($backtrace, true));
}
$DB->force_transaction_rollback();
}
// Close sessions - do it here to make it consistent for all session handlers.
\core\session\manager::write_close();
// Other cleanup.
self::request_shutdown();
// Stop profiling.
if (function_exists('profiling_is_running')) {
if (profiling_is_running()) {
profiling_stop();
}
}
// NOTE: do not dispose $DB and MUC here, they might be used from legacy shutdown functions.
}
示例4: profiling_stop
/**
* Stop profiling, gathering results and storing them
*/
function profiling_stop()
{
global $CFG, $DB, $SCRIPT;
// If profiling isn't available, nothing to stop
if (!extension_loaded('xhprof') || !function_exists('xhprof_enable')) {
return false;
}
// If profiling isn't enabled, nothing to stop
if (empty($CFG->profilingenabled) && empty($CFG->earlyprofilingenabled)) {
return false;
}
// If profiling is not running or is already saved, nothing to stop
if (!profiling_is_running() || profiling_is_saved()) {
return false;
}
// Set script (from global if available, else our own)
$script = !empty($SCRIPT) ? $SCRIPT : profiling_get_script();
// Arrived here, profiling is running, stop and save everything
profiling_is_running(false);
$data = xhprof_disable();
// We only save the run after ensuring the DB table exists
// (this prevents problems with profiling runs enabled in
// config.php before Moodle is installed. Rare but...
$tables = $DB->get_tables();
if (!in_array('profiling', $tables)) {
return false;
}
$run = new moodle_xhprofrun();
$run->prepare_run($script);
$runid = $run->save_run($data, null);
profiling_is_saved(true);
// Prune old runs
profiling_prune_old_runs($runid);
// Finished, return true
return true;
}
示例5: profiling_stop
/**
* Stop profiling, gathering results and storing them
*/
function profiling_stop() {
global $CFG, $SCRIPT;
// If profiling isn't available, nothing to stop
if (!extension_loaded('xhprof') || !function_exists('xhprof_enable')) {
return false;
}
// If profiling isn't enabled, nothing to stop
if (!$CFG->profilingenabled) {
return false;
}
// If profiling is not running or is already saved, nothing to stop
if (!profiling_is_running() || profiling_is_saved()) {
return false;
}
// Arrived here, profiling is running, stop and save everything
profiling_is_running(false);
$data = xhprof_disable();
$run = new moodle_xhprofrun();
$run->prepare_run($SCRIPT);
$runid = $run->save_run($data, null);
profiling_is_saved(true);
// Prune old runs
profiling_prune_old_runs($runid);
}
示例6: standard_footer_html
/**
* The standard tags (typically performance information and validation links,
* if we are in developer debug mode) that should be output in the footer area
* of the page. Designed to be called in theme layout.php files.
*
* @return string HTML fragment.
*/
public function standard_footer_html()
{
global $CFG, $SCRIPT;
// This function is normally called from a layout.php file in {@link core_renderer::header()}
// but some of the content will not be known until later, so we return a placeholder for now.
// This will be replaced with the real content in {@link core_renderer::footer()}.
$output = $this->unique_performance_info_token;
if ($this->page->devicetypeinuse == 'legacy') {
// The legacy theme is in use print the notification
$output .= html_writer::tag('div', get_string('legacythemeinuse'), array('class' => 'legacythemeinuse'));
}
// Get links to switch device types (only shown for users not on a default device)
$output .= $this->theme_switch_links();
if (!empty($CFG->debugpageinfo)) {
$icon = 'fa fa-cogs';
$text = 'This page is ';
$itag = html_writer::tag('i', '', array('class' => $icon));
$output .= html_writer::tag('div', $itag . $text . $this->page->debug_summary(), array('class' => 'performanceinfo pageinfo well'));
}
if (debugging(null, DEBUG_DEVELOPER) and has_capability('moodle/site:config', context_system::instance())) {
// Only in developer mode
// Add link to profiling report if necessary
if (function_exists('profiling_is_running') && profiling_is_running()) {
$txt = get_string('profiledscript', 'admin');
$title = get_string('profiledscriptview', 'admin');
$url = $CFG->wwwroot . '/admin/tool/profiling/index.php?script=' . urlencode($SCRIPT);
$link = html_writer::link($url, $txt, array('title' => $title));
$output .= html_writer::tag('div', $link, array('class' => 'profilingfooter'));
}
$url = new moodle_url('/' . $CFG->admin . '/purgecaches.php?confirm=1&sesskey=' . sesskey());
$purgecaches = get_string('purgecaches', 'admin');
$output .= '<div class="btn btn-default">';
$output .= '<a href=" ' . $url . ' "><i class="fa fa-trash"></i> ' . $purgecaches . ' </a>';
$output .= '</div>';
}
if (!empty($CFG->debugvalidators)) {
// NOTE: this is not a nice hack, $PAGE->url is not always accurate and $FULLME neither, it is not a bug if it fails. --skodak
$output .= '<div class="validators"><ul>
<li><a class="btn btn-small btn-default" href="http://validator.w3.org/check?verbose=1&ss=1&uri=' . urlencode(qualified_me()) . '"><i class="fa fa-cogs"></i> Validate HTML</a></li>
<li><a class="btn btn-small btn-default" href="http://www.contentquality.com/mynewtester/cynthia.exe?rptmode=-1&url1=' . urlencode(qualified_me()) . '"><i class="fa fa-cogs"></i> Section 508 Check</a></li>
<li><a class="btn btn-small btn-default" href="http://www.contentquality.com/mynewtester/cynthia.exe?rptmode=0&warnp2n3e=1&url1=' . urlencode(qualified_me()) . '"><i class="fa fa-cogs"></i> WCAG 1 (2,3) Check</a></li>
</ul><br /></div>';
}
if (!empty($CFG->additionalhtmlfooter)) {
$output .= "\n" . $CFG->additionalhtmlfooter;
}
return $output;
}