本文整理汇总了PHP中get_performance_info函数的典型用法代码示例。如果您正苦于以下问题:PHP get_performance_info函数的具体用法?PHP get_performance_info怎么用?PHP get_performance_info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_performance_info函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: footer
/**
* Outputs the page's footer
* @return string HTML fragment
*/
public function footer()
{
global $CFG, $DB, $USER;
$output = $this->container_end_all(true);
$footer = $this->opencontainers->pop('header/footer');
if (debugging() and $DB and $DB->is_transaction_started()) {
// TODO: MDL-20625 print warning - transaction will be rolled back
}
// Provide some performance info if required
$performanceinfo = '';
if (defined('MDL_PERF') || (!empty($CFG->perfdebug) and $CFG->perfdebug > 7)) {
$perf = get_performance_info();
if (defined('MDL_PERFTOLOG') && !function_exists('register_shutdown_function')) {
error_log("PERF: " . $perf['txt']);
}
if (defined('MDL_PERFTOFOOT') || debugging() || $CFG->perfdebug > 7) {
$performanceinfo = krystle_performance_output($perf);
}
}
$perftoken = property_exists($this, "unique_performance_info_token") ? $this->unique_performance_info_token : self::PERFORMANCE_INFO_TOKEN;
$endhtmltoken = property_exists($this, "unique_end_html_token") ? $this->unique_end_html_token : self::END_HTML_TOKEN;
$footer = str_replace($perftoken, $performanceinfo, $footer);
$footer = str_replace($endhtmltoken, $this->page->requires->get_end_code(), $footer);
$this->page->set_state(moodle_page::STATE_DONE);
if (!empty($this->page->theme->settings->persistentedit) && property_exists($USER, 'editing') && $USER->editing && !$this->really_editing) {
$USER->editing = false;
}
return $output . $footer;
}
开发者ID:roelmann,项目名称:krystle,代码行数:33,代码来源:renderers.php
示例2: footer
/**
* Outputs the page's footer
* @return string HTML fragment
*/
public function footer() {
global $CFG, $DB;
$output = $this->container_end_all(true);
$footer = $this->opencontainers->pop('header/footer');
if (debugging() and $DB and $DB->is_transaction_started()) {
// TODO: MDL-20625 print warning - transaction will be rolled back
}
// Provide some performance info if required
$performanceinfo = '';
if (defined('MDL_PERF') || (!empty($CFG->perfdebug) and $CFG->perfdebug > 7)) {
$perf = get_performance_info();
if (defined('MDL_PERFTOLOG') && !function_exists('register_shutdown_function')) {
error_log("PERF: " . $perf['txt']);
}
if (defined('MDL_PERFTOFOOT') || debugging() || $CFG->perfdebug > 7) {
$performanceinfo = krystle2_performance_output($perf);
}
}
$footer = str_replace(self::PERFORMANCE_INFO_TOKEN, $performanceinfo, $footer);
$footer = str_replace(self::END_HTML_TOKEN, $this->page->requires->get_end_code(), $footer);
$this->page->set_state(moodle_page::STATE_DONE);
return $output . $footer;
}
开发者ID:roelmann,项目名称:krystle2,代码行数:34,代码来源:renderers.php
示例3: Dwoo_Plugin_mahara_performance_info
/**
* Dwoo {mahara_performance_info} function plugin
*
* Type: function<br>
* Name: mahara_performance_info<br>
* Date: June 22, 2006<br>
* Purpose: Fetch internationalized strings
* @author Catalyst IT Ltd
* @version 1.0
* @return html to display in the footer.
*/
function Dwoo_Plugin_mahara_performance_info(Dwoo $dwoo)
{
if (!get_config('perftofoot') && !get_config('perftolog')) {
return;
}
$info = get_performance_info();
$dwoo = smarty_core();
foreach ($info as $key => $value) {
if ($key == 'realtime') {
$value = round($value, 3);
}
$dwoo->assign('perf_' . $key, $value);
}
// extras
$dwoo->assign('perf_memory_total_display', display_size($info['memory_total']));
$dwoo->assign('perf_memory_growth_display', display_size($info['memory_growth']));
if (get_config('perftolog')) {
perf_to_log($info);
}
if (get_config('perftofoot')) {
return $dwoo->fetch('performancefooter.tpl');
}
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:34,代码来源:function.mahara_performance_info.php
示例4: footer
/**
* Outputs the page's footer
* @return string HTML fragment
*/
public function footer()
{
global $CFG, $USER;
$output = $this->container_end_all(true);
$footer = $this->opencontainers->pop('header/footer');
// Provide some performance info if required
$performanceinfo = '';
if (defined('MDL_PERF') || (!empty($CFG->perfdebug) and $CFG->perfdebug > 7)) {
$perf = get_performance_info();
if (defined('MDL_PERFTOLOG') && !function_exists('register_shutdown_function')) {
error_log("PERF: " . $perf['txt']);
}
if (defined('MDL_PERFTOFOOT') || debugging() || $CFG->perfdebug > 7) {
$performanceinfo = essential_performance_output($perf);
}
}
$footer = str_replace($this->unique_performance_info_token, $performanceinfo, $footer);
$footer = str_replace($this->unique_end_html_token, $this->page->requires->get_end_code(), $footer);
$this->page->set_state(moodle_page::STATE_DONE);
if (!empty($this->page->theme->settings->persistentedit) && property_exists($USER, 'editing') && $USER->editing && !$this->really_editing) {
$USER->editing = false;
}
return $output . $footer;
}
开发者ID:phluzern,项目名称:moodle_theme_essential,代码行数:28,代码来源:core_renderer.php
示例5: footer
/**
* Outputs the page's footer
*
* @return string HTML fragment
*/
public function footer() {
global $CFG, $DB;
$output = $this->container_end_all(true);
$footer = $this->opencontainers->pop('header/footer');
if (debugging() and $DB and $DB->is_transaction_started()) {
// TODO: MDL-20625 print warning - transaction will be rolled back
}
// Provide some performance info if required
$performanceinfo = '';
if (defined('MDL_PERF') || (!empty($CFG->perfdebug) and $CFG->perfdebug > 7)) {
$perf = get_performance_info();
if (defined('MDL_PERFTOFOOT') || debugging() || $CFG->perfdebug > 7) {
$performanceinfo = $perf['html'];
}
}
// We always want performance data when running a performance test, even if the user is redirected to another page.
if (MDL_PERF_TEST && strpos($footer, $this->unique_performance_info_token) === false) {
$footer = $this->unique_performance_info_token . $footer;
}
$footer = str_replace($this->unique_performance_info_token, $performanceinfo, $footer);
$footer = str_replace($this->unique_end_html_token, $this->page->requires->get_end_code(), $footer);
$this->page->set_state(moodle_page::STATE_DONE);
return $output . $footer;
}
开发者ID:afgal,项目名称:moodle-1,代码行数:37,代码来源:outputrenderers.php
示例6: footer
/**
* Outputs the page's footer
* @return string HTML fragment
*/
public function footer()
{
global $CFG;
$output = $this->container_end_all(true);
$footer = $this->opencontainers->pop('header/footer');
// Provide some performance info if required.
$performanceinfo = '';
if (defined('MDL_PERF') || (!empty($CFG->perfdebug) and $CFG->perfdebug > 7)) {
$perf = get_performance_info();
if (defined('MDL_PERFTOLOG') && !function_exists('register_shutdown_function')) {
// @codingStandardsIgnoreStart
error_log("PERF: " . $perf['txt']);
// @codingStandardsIgnoreEnd
}
if (defined('MDL_PERFTOFOOT') || debugging() || $CFG->perfdebug > 7) {
$performanceinfo = $this->performance_output($perf, \theme_essential\toolbox::get_setting('perfinfo'));
}
}
$footer = str_replace($this->unique_performance_info_token, $performanceinfo, $footer);
$footer = str_replace($this->unique_end_html_token, $this->page->requires->get_end_code(), $footer);
$this->page->set_state(moodle_page::STATE_DONE);
$info = '<!-- Essential theme version: ' . $this->page->theme->settings->version . ', developed, enhanced and maintained by Gareth J Barnard: about.me/gjbarnard -->';
return $output . $footer . $info;
}
开发者ID:julenpardo,项目名称:moodle-theme_essential,代码行数:28,代码来源:core_renderer.php
示例7: redirect
/**
* Redirects the user to another page, after printing a notice
*
* @param string $url The url to take the user to
* @param string $message The text message to display to the user about the redirect, if any
* @param string $delay How long before refreshing to the new page at $url?
* @todo '&' needs to be encoded into '&' for XHTML compliance,
* however, this is not true for javascript. Therefore we
* first decode all entities in $url (since we cannot rely on)
* the correct input) and then encode for where it's needed
* echo "<script type='text/javascript'>alert('Redirect $url');</script>";
*/
function redirect($url, $message = '', $delay = -1)
{
global $CFG, $THEME, $SESSION, $PAGE;
if (!empty($CFG->usesid) && !isset($_COOKIE[session_name()])) {
$url = $SESSION->sid_process_url($url);
}
$message = clean_text($message);
$encodedurl = preg_replace("/\\&(?![a-zA-Z0-9#]{1,8};)/", "&", $url);
$encodedurl = preg_replace('/^.*href="([^"]*)".*$/', "\\1", clean_text('<a href="' . $encodedurl . '" />'));
$url = str_replace('&', '&', $encodedurl);
/// At developer debug level. Don't redirect if errors have been printed on screen.
/// Currenly only works in PHP 5.2+; we do not want strict PHP5 errors
$lasterror = error_get_last();
$error = defined('DEBUGGING_PRINTED') or !empty($lasterror) && $lasterror['type'] & DEBUG_DEVELOPER;
$errorprinted = debugging('', DEBUG_ALL) && $CFG->debugdisplay && $error;
if ($errorprinted) {
$message = "<strong>Error output, so disabling automatic redirect.</strong></p><p>" . $message;
}
$performanceinfo = '';
if (defined('MDL_PERF') || (!empty($CFG->perfdebug) and $CFG->perfdebug > 7)) {
if (defined('MDL_PERFTOLOG') && !function_exists('register_shutdown_function')) {
$perf = get_performance_info();
error_log("PERF: " . $perf['txt']);
}
}
/// when no message and header printed yet, try to redirect
if (empty($message) and !$PAGE->headerprinted) {
// Technically, HTTP/1.1 requires Location: header to contain
// the absolute path. (In practice browsers accept relative
// paths - but still, might as well do it properly.)
// This code turns relative into absolute.
if (!preg_match('|^[a-z]+:|', $url)) {
// Get host name http://www.wherever.com
$hostpart = preg_replace('|^(.*?[^:/])/.*$|', '$1', $CFG->wwwroot);
if (preg_match('|^/|', $url)) {
// URLs beginning with / are relative to web server root so we just add them in
$url = $hostpart . $url;
} else {
// URLs not beginning with / are relative to path of current script, so add that on.
$url = $hostpart . preg_replace('|\\?.*$|', '', me()) . '/../' . $url;
}
// Replace all ..s
while (true) {
$newurl = preg_replace('|/(?!\\.\\.)[^/]*/\\.\\./|', '/', $url);
if ($newurl == $url) {
break;
}
$url = $newurl;
}
}
$delay = 0;
//try header redirection first
@header($_SERVER['SERVER_PROTOCOL'] . ' 303 See Other');
//302 might not work for POST requests, 303 is ignored by obsolete clients
@header('Location: ' . $url);
//another way for older browsers and already sent headers (eg trailing whitespace in config.php)
echo '<meta http-equiv="refresh" content="' . $delay . '; url=' . $encodedurl . '" />';
print_js_call('document.location.replace', array($url));
die;
}
if ($delay == -1) {
$delay = 3;
// if no delay specified wait 3 seconds
}
if (!$PAGE->headerprinted) {
// this type of redirect might not be working in some browsers - such as lynx :-(
print_header('', '', '', '', $errorprinted ? '' : '<meta http-equiv="refresh" content="' . $delay . '; url=' . $encodedurl . '" />');
$delay += 3;
// double redirect prevention, it was sometimes breaking upgrades before 1.7
} else {
print_container_end_all(false, $THEME->open_header_containers);
}
echo '<div id="redirect">';
echo '<div id="message">' . $message . '</div>';
echo '<div id="continue">( <a href="' . $encodedurl . '">' . get_string('continue') . '</a> )</div>';
echo '</div>';
if (!$errorprinted) {
print_delayed_js_call($delay, 'document.location.replace', array($url));
}
$CFG->docroot = false;
// to prevent the link to moodle docs from being displayed on redirect page.
print_footer('none');
die;
}
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:96,代码来源:weblib.php
示例8: moodle_request_shutdown
function moodle_request_shutdown()
{
global $CFG;
// initially, we are only ever called under apache
// but check just in case
if (function_exists('apache_child_terminate') && function_exists('memory_get_usage') && ini_get_bool('child_terminate')) {
if (empty($CFG->apachemaxmem)) {
$CFG->apachemaxmem = 25000000;
// default 25MiB
}
if (memory_get_usage() > (int) $CFG->apachemaxmem) {
trigger_error('Mem usage over $CFG->apachemaxmem: marking child for reaping.');
@apache_child_terminate();
}
}
if (defined('MDL_PERF') || (!empty($CFG->perfdebug) and $CFG->perfdebug > 7)) {
if (defined('MDL_PERFTOLOG')) {
$perf = get_performance_info();
error_log("PERF: " . $perf['txt']);
}
if (defined('MDL_PERFINC')) {
$inc = get_included_files();
$ts = 0;
foreach ($inc as $f) {
if (preg_match(':^/:', $f)) {
$fs = filesize($f);
$ts += $fs;
$hfs = display_size($fs);
error_log(substr($f, strlen($CFG->dirroot)) . " size: {$fs} ({$hfs})", NULL, NULL, 0);
} else {
error_log($f, NULL, NULL, 0);
}
}
if ($ts > 0) {
$hts = display_size($ts);
error_log("Total size of files included: {$ts} ({$hts})");
}
}
}
}
开发者ID:nadavkav,项目名称:rtlMoodle,代码行数:40,代码来源:moodlelib.php
示例9: moodle_request_shutdown
/**
* This function expects to called during shutdown
* should be set via register_shutdown_function()
* in lib/setup.php .
*
* @return void
*/
function moodle_request_shutdown()
{
global $CFG;
// help apache server if possible
$apachereleasemem = false;
if (function_exists('apache_child_terminate') && function_exists('memory_get_usage') && ini_get_bool('child_terminate')) {
$limit = empty($CFG->apachemaxmem) ? 64 * 1024 * 1024 : $CFG->apachemaxmem;
//64MB default
if (memory_get_usage() > get_real_size($limit)) {
$apachereleasemem = $limit;
@apache_child_terminate();
}
}
// deal with perf logging
if (defined('MDL_PERF') || (!empty($CFG->perfdebug) and $CFG->perfdebug > 7)) {
if ($apachereleasemem) {
error_log('Mem usage over ' . $apachereleasemem . ': marking Apache child for reaping.');
}
if (defined('MDL_PERFTOLOG')) {
$perf = get_performance_info();
error_log("PERF: " . $perf['txt']);
}
if (defined('MDL_PERFINC')) {
$inc = get_included_files();
$ts = 0;
foreach ($inc as $f) {
if (preg_match(':^/:', $f)) {
$fs = filesize($f);
$ts += $fs;
$hfs = display_size($fs);
error_log(substr($f, strlen($CFG->dirroot)) . " size: {$fs} ({$hfs})", NULL, NULL, 0);
} else {
error_log($f, NULL, NULL, 0);
}
}
if ($ts > 0) {
$hts = display_size($ts);
error_log("Total size of files included: {$ts} ({$hts})");
}
}
}
}
开发者ID:hitphp,项目名称:moodle,代码行数:49,代码来源:moodlelib.php
示例10: redirect
/**
* Redirects the user to another page, after printing a notice
*
* @param string $url The url to take the user to
* @param string $message The text message to display to the user about the redirect, if any
* @param string $delay How long before refreshing to the new page at $url?
* @todo '&' needs to be encoded into '&' for XHTML compliance,
* however, this is not true for javascript. Therefore we
* first decode all entities in $url (since we cannot rely on)
* the correct input) and then encode for where it's needed
* echo "<script type='text/javascript'>alert('Redirect $url');</script>";
*/
function redirect($url, $message = '', $delay = -1, $adminroot = '')
{
global $CFG;
if (!empty($CFG->usesid) && !isset($_COOKIE[session_name()])) {
$url = sid_process_url($url);
}
$message = clean_text($message);
$url = html_entity_decode($url);
$url = str_replace(array("\n", "\r"), '', $url);
// some more cleaning
$encodedurl = htmlentities($url);
$tmpstr = clean_text('<a href="' . $encodedurl . '" />');
//clean encoded URL
$encodedurl = substr($tmpstr, 9, strlen($tmpstr) - 13);
$url = html_entity_decode($encodedurl);
$surl = addslashes($url);
$performanceinfo = '';
if (defined('MDL_PERF') || (!empty($CFG->perfdebug) and $CFG->perfdebug > 7)) {
if (defined('MDL_PERFTOLOG') && !function_exists('register_shutdown_function')) {
$perf = get_performance_info();
error_log("PERF: " . $perf['txt']);
}
}
/// when no message and header printed yet, try to redirect
if (empty($message) and !defined('HEADER_PRINTED')) {
// Technically, HTTP/1.1 requires Location: header to contain
// the absolute path. (In practice browsers accept relative
// paths - but still, might as well do it properly.)
// This code turns relative into absolute.
if (!preg_match('|^[a-z]+:|', $url)) {
// Get host name http://www.wherever.com
$hostpart = preg_replace('|^(.*?[^:/])/.*$|', '$1', $CFG->wwwroot);
if (preg_match('|^/|', $url)) {
// URLs beginning with / are relative to web server root so we just add them in
$url = $hostpart . $url;
} else {
// URLs not beginning with / are relative to path of current script, so add that on.
$url = $hostpart . preg_replace('|\\?.*$|', '', me()) . '/../' . $url;
}
// Replace all ..s
while (true) {
$newurl = preg_replace('|/(?!\\.\\.)[^/]*/\\.\\./|', '/', $url);
if ($newurl == $url) {
break;
}
$url = $newurl;
}
}
$delay = 0;
//try header redirection first
@header($_SERVER['SERVER_PROTOCOL'] . ' 303 See Other');
//302 might not work for POST requests, 303 is ignored by obsolete clients
@header('Location: ' . $url);
//another way for older browsers and already sent headers (eg trailing whitespace in config.php)
echo '<meta http-equiv="refresh" content="' . $delay . '; url=' . $encodedurl . '" />';
echo '<script type="text/javascript">' . "\n" . '//<![CDATA[' . "\n" . "location.replace('{$surl}');" . "\n" . '//]]>' . "\n" . '</script>';
// To cope with Mozilla bug
die;
}
if ($delay == -1) {
$delay = 3;
// if no delay specified wait 3 seconds
}
if (!defined('HEADER_PRINTED')) {
// this type of redirect might not be working in some browsers - such as lynx :-(
print_header('', '', '', '', '<meta http-equiv="refresh" content="' . $delay . '; url=' . $encodedurl . '" />');
$delay += 3;
// double redirect prevention, it was sometimes breaking upgrades before 1.7
}
echo '<div style="text-align:center">';
echo '<div>' . $message . '</div>';
echo '<div>( <a href="' . $encodedurl . '">' . get_string('continue') . '</a> )</div>';
echo '</div>';
// it might be better not to set timeout the same for both types of redirect, so that we can be sure which one wins
?>
<script type="text/javascript">
//<![CDATA[
function redirect() {
document.location.replace('<?php
echo $surl;
?>
');
}
setTimeout("redirect()", <?php
echo $delay * 1000;
?>
);
//.........这里部分代码省略.........
开发者ID:veritech,项目名称:pare-project,代码行数:101,代码来源:weblib.php
示例11: perf_to_log
function perf_to_log($info = null)
{
if (!get_config('perftolog')) {
return true;
}
if (empty($info)) {
$info = get_performance_info();
}
$logstring = 'PERF: ' . strip_querystring(get_script_path()) . ': ';
$logstring .= ' memory_total: ' . $info['memory_total'] . 'B (' . display_size($info['memory_total']) . ') memory_growth: ' . $info['memory_growth'] . 'B (' . display_size($info['memory_growth']) . ')';
$logstring .= ' time: ' . $info['realtime'] . 's';
$logstring .= ' includecount: ' . $info['includecount'];
$logstring .= ' dbqueries: ' . $info['dbreads'] . ' reads, ' . $info['dbwrites'] . ' writes, ' . $info['dbcached'] . ' cached';
$logstring .= ' ticks: ' . $info['ticks'] . ' user: ' . $info['utime'] . ' sys: ' . $info['stime'] . ' cuser: ' . $info['cutime'] . ' csys: ' . $info['cstime'];
$logstring .= ' serverload: ' . $info['serverload'];
log_debug($logstring);
}
开发者ID:kienv,项目名称:mahara,代码行数:17,代码来源:mahara.php
示例12: templates_variables_substitute
function templates_variables_substitute($param)
{
global $CFG;
$variables = $param[0];
$template_variable = $param[1];
$run_result = '';
// Substitute variables in templates:
// where {{variablename}} is found in the template, this function is passed
// "variablename" and returns the proper variable
global $menubar;
global $submenubar;
global $metatags;
global $PAGE;
global $template_id;
//error_log("tvs " . print_r($template_variable,1));
if (isset($variables[$template_variable])) {
return $variables[$template_variable];
} else {
switch ($template_variable) {
case "username":
if (logged_on) {
return $_SESSION['username'];
} else {
return gettext("Guest");
}
break;
case "userfullname":
if (logged_on) {
return htmlspecialchars($_SESSION['name'], ENT_COMPAT, 'utf-8');
} else {
return gettext("Guest") . " [<a href=\"" . url . "login/index.php\">" . gettext("Log in") . "</a>]";
}
break;
// case "userfullname":
// global $page_owner;
// if (!isset($page_owner) || $page_owner == -1) {
// return "";
// } else {
// return run("users:id_to_name", $page_owner);
// }
// break;
// case "userfullname":
// global $page_owner;
// if (!isset($page_owner) || $page_owner == -1) {
// return "";
// } else {
// return run("users:id_to_name", $page_owner);
// }
// break;
case "menu":
if (logged_on) {
return templates_draw(array('menuitems' => menu_join('', $PAGE->menu), 'context' => 'menu'));
}
break;
case "submenu":
return templates_draw(array('submenuitems' => menu_join(' | ', $PAGE->menu_sub), 'context' => 'submenu'));
break;
case "topmenu":
if (logged_on) {
return templates_draw(array('topmenuitems' => menu_join('', $PAGE->menu_top), 'context' => 'topmenu'));
}
break;
case "url":
return url;
break;
case "metatags":
// $run_result = "<link href=\"/".$template_variable.".css\" rel=\"stylesheet\" type=\"text/css\" />";
return "<style type=\"text/css\"><!--\n" . templates_draw(array('template' => $template_id, 'context' => 'css')) . "// -->\n</style>\n" . $metatags;
break;
case 'perf':
$perf = get_performance_info();
if (defined('ELGG_PERFTOLOG')) {
error_log("PERF: " . $perf['txt']);
}
if (defined('ELGG_PERFTOFOOT') || $CFG->debug > 7 || $CFG->perfdebug > 7) {
return $perf['html'];
}
break;
}
}
return $run_result;
}
开发者ID:pzingg,项目名称:saugus_elgg,代码行数:82,代码来源:templates.php
示例13: plain_page
/**
* Output basic html page.
* @static
* @param string $title page title
* @param string $content page content
* @param string $meta meta tag
* @return string html page
*/
public static function plain_page($title, $content, $meta = '')
{
if (function_exists('get_string') && function_exists('get_html_lang')) {
$htmllang = get_html_lang();
} else {
$htmllang = '';
}
$footer = '';
if (MDL_PERF_TEST) {
$perfinfo = get_performance_info();
$footer = '<footer>' . $perfinfo['html'] . '</footer>';
}
return '<!DOCTYPE html>
<html ' . $htmllang . '>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
' . $meta . '
<title>' . $title . '</title>
</head><body>' . $content . $footer . '</body></html>';
}
开发者ID:abhilash1994,项目名称:moodle,代码行数:28,代码来源:setuplib.php
示例14: footer
/**
* Outputs the page's footer
* @return string HTML fragment
*/
public function footer()
{
$output = $this->opencontainers->pop_all_but_last(true);
$footer = $this->opencontainers->pop('header/footer');
// Provide some performance info if required
$performanceinfo = '';
if (defined('MDL_PERF') || (!empty($CFG->perfdebug) and $CFG->perfdebug > 7)) {
$perf = get_performance_info();
if (defined('MDL_PERFTOLOG') && !function_exists('register_shutdown_function')) {
error_log("PERF: " . $perf['txt']);
}
if (defined('MDL_PERFTOFOOT') || debugging() || $CFG->perfdebug > 7) {
$performanceinfo = $perf['html'];
}
}
$footer = str_replace(self::PERFORMANCE_INFO_TOKEN, $performanceinfo, $footer);
$footer = str_replace(self::END_HTML_TOKEN, $this->page->requires->get_end_code(), $footer);
$this->page->set_state(moodle_page::STATE_DONE);
return $output . $footer;
}
开发者ID:ajv,项目名称:Offline-Caching,代码行数:24,代码来源:outputrenderers.php
示例15: footer
/**
* Returns html to render footer
*
* @return string
*/
public function footer() {
global $CFG;
$output = $this->container_end_all(true);
$footer = $this->opencontainers->pop('header/footer');
// Provide some performance info if required.
$performanceinfo = '';
if (defined('MDL_PERF') || (!empty($CFG->perfdebug) and $CFG->perfdebug > 7)) {
$perf = get_performance_info();
// Deprecated function. Display: The use of function error_log() is forbidden.
// if (defined('MDL_PERFTOLOG') && !function_exists('register_shutdown_function')) {.
// error_log("PERF: " . $perf['txt']);.
// }.
if (defined('MDL_PERFTOFOOT') || debugging() || $CFG->perfdebug > 7) {
$performanceinfo = theme_adaptable_performance_output($perf);
}
}
$footer = str_replace($this->unique_performance_info_token, $performanceinfo, $footer);
$footer = str_replace($this->unique_end_html_token, $this->page->requires->get_end_code(), $footer);
$this->page->set_state(moodle_page::STATE_DONE);
return $output . $footer;
}
开发者ID:educacionbe,项目名称:campus,代码行数:35,代码来源:renderers.php
示例16: templates_variables_substitute
function templates_variables_substitute($param)
{
global $CFG;
$variables = $param[0];
$template_variable = $param[1];
$run_result = '';
// Substitute variables in templates:
// where {{variablename}} is found in the template, this function is passed
// "variablename" and returns the proper variable
global $menubar;
global $submenubar;
global $metatags;
global $PAGE;
global $template_id;
global $template_name;
global $db;
//error_log("tvs " . print_r($template_variable,1));
$result = "";
if (isset($variables[$template_variable])) {
$result .= $variables[$template_variable];
} else {
$vars = array();
if (substr_count($template_variable, ":") > 0) {
$vars = explode(":", $template_variable);
$template_variable = $vars[0];
}
switch ($template_variable) {
case "username":
if (logged_on) {
$result = $_SESSION['username'];
} else {
$result = __gettext("Guest");
}
break;
case "usericonid":
if (logged_on) {
$result = user_info("icon", $_SESSION['userid']);
} else {
$result = 0;
}
break;
case "name":
if (logged_on) {
$result = htmlspecialchars($_SESSION['name'], ENT_COMPAT, 'utf-8');
} else {
$result = __gettext("Guest");
}
break;
case "userfullname":
if (logged_on) {
$result = __gettext("Welcome") . " " . htmlspecialchars($_SESSION['name'], ENT_COMPAT, 'utf-8');
} else {
$result = __gettext("Welcome") . " " . __gettext("Guest") . " [<a href=\"" . url . "login/index.php\">" . __gettext("Log in") . "</a>]";
}
break;
case "menu":
if (logged_on) {
$result = templates_draw(array('menuitems' => menu_join('', $PAGE->menu), 'context' => 'menu'));
}
break;
case "submenu":
$result = templates_draw(array('submenuitems' => menu_join(' | ', $PAGE->menu_sub), 'context' => 'submenu'));
break;
case "topmenu":
$result = templates_draw(array('topmenuitems' => menu_join('', $PAGE->menu_top), 'context' => 'topmenu'));
break;
case "url":
$result = url;
break;
case "sitename":
$result = $CFG->sitename;
break;
case "tagline":
$result = $CFG->tagline;
break;
case "metatags":
if (!empty($template_name)) {
// use a defined style
$result = '<link href="' . $CFG->wwwroot . '_templates/css/' . $template_name . '" rel="stylesheet" type="text/css" />' . "\n";
} else {
// use whatever's in $template['css']
$result = "<style type=\"text/css\">\n" . templates_draw(array('template' => $template_name, 'context' => 'css')) . "\n</style>\n";
}
// locate css at end
$result = $metatags . "\n" . $result;
break;
case 'perf':
$perf = get_performance_info();
if (defined('ELGG_PERFTOLOG')) {
error_log("PERF: " . $perf['txt']);
}
if (defined('ELGG_PERFTOFOOT') || $CFG->debug > 7 || $CFG->perfdebug > 7) {
$result = $perf['html'];
}
break;
case 'randomusers':
$result = "";
if (isset($vars[1])) {
$vars[1] = (int) $vars[1];
} else {
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:tulipan-svn,代码行数:101,代码来源:templates.php
示例17: redirect
/**
* Redirects the user to another page, after printing a notice
*
* This function calls the OUTPUT redirect method, echo's the output
* and then dies to ensure nothing else happens.
*
* <strong>Good practice:</strong> You should call this method before starting page
* output by using any of the OUTPUT methods.
*
* @param moodle_url $url A moodle_url to redirect to. Strings are not to be trusted!
* @param string $message The message to display to the user
* @param int $delay The delay before redirecting
* @return void
*/
function redirect($url, $message = '', $delay = -1)
{
global $OUTPUT, $SESSION, $CFG;
if ($url instanceof moodle_url) {
$url = $url->out(false, array(), false);
}
if (!empty($CFG->usesid) && !isset($_COOKIE[session_name()])) {
$url = $SESSION->sid_process_url($url);
}
$lasterror = error_get_last();
$debugdisableredirect = defined('DEBUGGING_PRINTED') || !empty($CFG->debugdisplay) && !empty($lasterror) && $lasterror['type'] & DEBUG_DEVELOPER;
$usingmsg = false;
if (!empty($message)) {
if ($delay === -1 || !is_numeric($delay)) {
$delay = 3;
}
$message = clean_text($message);
} else {
$message = get_string('pageshouldredirect');
$delay = 0;
// We are going to try to use a HTTP redirect, so we need a full URL.
if (!preg_match('|^[a-z]+:|', $url)) {
// Get host name http://www.wherever.com
$hostpart = preg_replace('|^(.*?[^:/])/.*$|', '$1', $CFG->wwwroot);
if (preg_match('|^/|', $url)) {
// URLs beginning with / are relative to web server root so we just add them in
$url = $hostpart . $url;
} else {
// URLs not beginning with / are relative to path of current script, so add that on.
$url = $hostpart . preg_replace('|\\?.*$|', '', me()) . '/../' . $url;
}
// Replace all ..s
while (true) {
$newurl = preg_replace('|/(?!\\.\\.)[^/]*/\\.\\./|', '/', $url);
if ($newurl == $url) {
break;
}
$url = $newurl;
}
}
}
if (defined('MDL_PERF') || (!empty($CFG->perfdebug) and $CFG->perfdebug > 7)) {
if (defined('MDL_PERFTOLOG') && !function_exists('register_shutdown_function')) {
$perf = get_performance_info();
error_log("PERF: " . $perf['txt']);
}
}
$encodedurl = preg_replace("/\\&(?![a-zA-Z0-9#]{1,8};)/", "&", $url);
$encodedurl = preg_replace('/^.*href="([^"]*)".*$/', "\\1", clean_text('<a href="' . $encodedurl . '" />'));
if ($delay == 0 && !$debugdisableredirect && !headers_sent()) {
//302 might not work for POST requests, 303 is ignored by obsolete clients.
@header($_SERVER['SERVER_PROTOCOL'] . ' 303 See Other');
@header('Location: ' . $url);
echo bootstrap_renderer::plain_redirect_message($encodedurl);
exit;
}
// Include a redirect message, even with a HTTP redirect, because that is recommended practice.
$CFG->docroot = false;
// to prevent the link to moodle docs from being displayed on redirect page.
echo $OUTPUT->redirect_message($encodedurl, $message, $delay, $debugdisableredirect);
exit;
}
开发者ID:ajv,项目名称:Offline-Caching,代码行数:76,代码来源:weblib.php
示例18: redirect
/**
* Redirects the user to another page, after printing a notice
*
* This function calls the OUTPUT redirect method, echo's the output
* and then dies to ensure nothing else happens.
*
* <strong>Good practice:</strong> You should call this method before starting page
* output by using any of the OUTPUT methods.
*
* @param moodle_url|string $url A moodle_url to redirect to. Strings are not to be trusted!
* @param string $message The message to display to the user
* @param int $delay The delay before redirecting
* @return void - does not return!
*/
function redirect($url, $message = '', $delay = -1)
{
global $OUTPUT, $PAGE, $SESSION, $CFG;
if (CLI_SCRIPT or AJAX_SCRIPT) {
// this is wrong - developers should not use redirect in these scripts,
// but it should not be very likely
throw new moodle_exception('redirecterrordetected', 'error');
}
// prevent debug errors - make sure context is properly initialised
if ($PAGE) {
$PAGE->set_context(null);
}
if ($url instanceof moodle_url) {
$url = $url->out(false);
}
if (!empty($CFG->usesid) && !isset($_COOKIE[session_name()])) {
$url = $SESSION->sid_process_url($url);
}
$debugdisableredirect = false;
do {
if (defined('DEBUGGING_PRINTED')) {
// some debugging already printed, no need to look more
$debugdisableredirect = true;
break;
}
if (empty
|
请发表评论