Commit 86e62673 authored by Vipo's avatar Vipo 💬

devbar

If you don't want reinstall only change in your config.php the line to TRUE
$config['enable_hooks'] = TRUE;
parent 04c5ca81
......@@ -39,7 +39,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
| $autoload['packages'] = array(APPPATH.'third_party', '/usr/local/shared');
|
*/
$autoload['packages'] = array();
$autoload['packages'] = array(APPPATH . 'third_party/DevelBar');
/*
| -------------------------------------------------------------------
......
......@@ -11,3 +11,10 @@ defined('BASEPATH') OR exit('No direct script access allowed');
| https://codeigniter.com/user_guide/general/hooks.html
|
*/
$hook['display_override'][] = array(
'class' => 'Develbar',
'function' => 'debug',
'filename' => 'Develbar.php',
'filepath' => 'third_party/DevelBar/hooks'
);
\ No newline at end of file
<?php
/**
* Class DevelBarProfiler
*
* Profiler Controller for ajax requests
*
* This content is released under the MIT License (MIT)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @package DevelBar
* @author Mohamed ES-SAHLI
* @license http://opensource.org/licenses/MIT MIT License
* @link https://github.com/JCSama/CodeIgniter-develbar
* @since Version 0.1
* @filesource
*/
class DevelBarProfiler extends CI_Controller
{
/**
* @param $profilerId
* @return string
*/
public function profil($profilerId)
{
$this->load->helper('url');
if (ENVIRONMENT != 'development') {
redirect();
}
$this->load->driver('cache', array('adapter' => 'file', 'key_prefix' => 'ci_toolbar_profiler_'));
$profiler = $this->cache->get($profilerId);
$this->load->helper(array('language', 'utility'));
$this->load_lang_file();
$data = array(
'profiler' => $profiler
);
$this->load->view('develbar/profiler', $data);
}
/**
* Load language file
*/
private function load_lang_file()
{
$default_language = $this->config->config['language'];
$lang_file = APPPATH . 'third_party/DevelBar/language/' . $default_language . '/develbar_lang.php';
if (!file_exists($lang_file)) {
$default_language = 'english';
}
$this->load->language('develbar', $default_language);
}
}
......@@ -3,4 +3,120 @@
/* load the MX_Loader class */
require APPPATH."third_party/MX/Loader.php";
class MY_Loader extends MX_Loader {}
\ No newline at end of file
class MY_Loader extends MX_Loader
{
/**
* List of loaded views
*
* @return array
*/
protected $_ci_views = array();
/**
* List of loaded helpers
*
* @return array
*/
public function get_helpers()
{
return $this->_ci_helpers;
}
/**
* List of loaded views
*
* @return array
*/
public function get_views()
{
return $this->_ci_views;
}
/**
* @return mixed
*/
public function get_models(){
return $this->_ci_models;
}
/**
* Internal CI Data Loader
*
* Used to load views and files.
*
* Variables are prefixed with _ci_ to avoid symbol collision with
* variables made available to view files.
*
* @used-by CI_Loader::view()
* @used-by CI_Loader::file()
*
* @param array $_ci_data Data to load
*
* @return object
*/
public function _ci_load($_ci_data)
{
extract($_ci_data);
if (isset($_ci_view))
{
$_ci_path = '';
/* add file extension if not provided */
$_ci_file = (pathinfo($_ci_view, PATHINFO_EXTENSION)) ? $_ci_view : $_ci_view.EXT;
foreach ($this->_ci_view_paths as $path => $cascade)
{
if (file_exists($view = $path.$_ci_file))
{
$_ci_path = $view;
break;
}
if ( ! $cascade) break;
}
}
elseif (isset($_ci_path))
{
$_ci_file = basename($_ci_path);
if( ! file_exists($_ci_path)) $_ci_path = '';
}
if (empty($_ci_path))
show_error('Unable to load the requested file: '.$_ci_file);
if (isset($_ci_vars))
$this->_ci_cached_vars = array_merge($this->_ci_cached_vars, (array) $_ci_vars);
extract($this->_ci_cached_vars);
ob_start();
if ((bool) @ini_get('short_open_tag') === FALSE && CI::$APP->config->item('rewrite_short_tags') == TRUE)
{
echo eval('?>'.preg_replace("/;*\s*\?>/", "; ?>", str_replace('<?=', '<?php echo ', file_get_contents($_ci_path))));
}
else
{
include($_ci_path);
}
// PATCH : Add the the loaded view file to the list
$this->_ci_views[$_ci_path] = isset($_ci_vars) ? $_ci_vars : array();
log_message('debug', 'File loaded: '.$_ci_path);
if ($_ci_return == TRUE) return ob_get_clean();
if (ob_get_level() > $this->_ci_ob_level + 1)
{
ob_end_flush();
}
else
{
CI::$APP->output->append_output(ob_get_clean());
}
}
}
\ No newline at end of file
.develbar{
font-family: Tahoma!important;
font-size:.8em!important;
position:fixed; bottom:0; left:0; width:100%; height:40px; color:#90949f; font-size:12px;
background: #2e313a; /* Old browsers */
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzJlMzEzYSIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiMyMDIxMjgiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-linear-gradient(top, #2e313a 0%, #202128 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#2e313a), color-stop(100%,#202128)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #2e313a 0%,#202128 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #2e313a 0%,#202128 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #2e313a 0%,#202128 100%); /* IE10+ */
background: linear-gradient(to bottom, #2e313a 0%,#202128 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#2e313a', endColorstr='#202128',GradientType=0 ); /* IE6-8 */
-moz-box-shadow: 0px -2px 5px 0px #999;
-webkit-box-shadow: 0px -2px 5px 0px #999;
-o-box-shadow: 0px -2px 5px 0px #999;
box-shadow: 0px -2px 5px 0px #999;
filter:progid:DXImageTransform.Microsoft.Shadow(color=#999, Direction=90, Strength=5);
}
.develbar p{ padding:2px 0; margin:0; overflow:hidden }
.develbar p::after{ content:''; clear:both }
.develbar p .left-col{ display:block; float:left; width:80% }
.develbar p .right-col{ display:block; float:right; color:#FFF }
.develbar .label{ padding:2px 4px; margin-right:2px;
font-size:11px; color:#FFF; -moz-border-radius:3px; -webkit-border-radius: 3px; border-radius:3px; }
.develbar .warning{ background:#F0AD4E; border-color:#EEA236 }
.develbar a{ color:#33BCEF; text-decoration:none }
.develbar a:hover{ color:#33BCEF; text-decoration:underline }
.develbar ul{ list-style:none; float:left; width:100%; padding-left:10px; padding-top:0; margin:0 }
.develbar ul li{ float:left; height:40px; cursor:default; position:relative; margin-right:10px; padding:0 4px }
.develbar ul li.none{ cursor:pointer }
.develbar ul li:hover{ border-color:#f03900; color:#FFF }
.develbar ul li img{ max-height:40px; max-width:40px; display: inline-block; vertical-align:middle; margin-right:2px; }
.develbar ul li:before { content: ' '; display: inline-block; vertical-align:middle; height: 100%; }
.develbar ul li div.detail{ min-width:200px; max-height:300px; color:#90949f; padding:6px 12px; display:none; position:absolute; left:0; bottom:40px; background:#2E313A;
border-bottom:2px solid transparent;
-moz-box-shadow: 0px -4px 5px 0px #999;
-webkit-box-shadow: 0px -4px 5px 0px #999;
-o-box-shadow: 0px -4px 5px 0px #999;
box-shadow: 0px -4px 5px 0px #999;
filter:progid:DXImageTransform.Microsoft.Shadow(color=#999, Direction=90, Strength=5);
-moz-border-radius: 5px;
-moz-border-radius-bottomleft:0;
-moz-border-radius-bottomright:0;
-webkit-border-radius: 5px;
-webkit-border-bottom-left-radius:0;
-webkit-border-bottom-right-radius:0;
border-radius: 5px;
border-bottom-right-radius:0;
border-bottom-left-radius:0;
}
.develbar ul li div.detail::after { content: ''; position: absolute; bottom:-8px; left:8px; width: 0; height: 0; border-left:6px solid transparent; border-right:6px solid transparent; border-top: 6px solid #f03900 }
.develbar ul li div.detail .scroll { min-width:200px; max-width:400px; max-height:280px; overflow:auto }
.develbar ul li.none div.detail::after { content: ''; border:0 }
.develbar ul li:hover div.detail, .develbar ul li.active div.detail{ display:block; border-color:#f03900 }
.develbar ul li div.benchmarks{ min-width:360px }
.develbar ul li div.database{ min-width:400px }
.develbar ul li div.views{ min-width:300px }
.develbar ul li div.hooks{ min-width:300px }
.develbar ul li div.config{ min-width:320px }
.develbar ul li div.models{ min-width:200px }
.develbar ul li div.ajax{ min-width:340px }
#develbar-off{ position:fixed; bottom:6px; left:14px; cursor:pointer; height:30px; display:none;
-moz-box-shadow: 0px 0px 5px 0px #999;
-webkit-box-shadow: 0px 0px 5px 0px #999;
-o-box-shadow: 0px 0px 5px 0px #999;
box-shadow: 0px 0px 5px 0px #999;
filter:progid:DXImageTransform.Microsoft.Shadow(color=#999, Direction=90, Strength=5);
-moz-border-radius:16px;
border-radius: 16px;
-webkit-border-radius:16px;
}
.develbar .ci-toolbar-status{ background-color:#666; color:#FFF; padding:2px 4px }
.develbar .ci-toolbar-status-red{ background-color:#FF0000; color:#FFF; padding:2px 4px }
.develbar .ci-ajax-request-loading{ background-color:#F9AA20; color:#FFF; padding:2px 4px }
.develbar .ci-toolbar-ajax-info{ border-bottom:1px solid #666 }
.develbar .ci-toolbar-ajax-head{ background-color: #000; border:0; margin:0; padding:0 }
.develbar .ci-toolbar-ajax-table td{ vertical-align:top; padding:2px 3px }
CIjs=function(){"use strict";var j,a=function(a,b){return a.className.match(new RegExp("\\b"+b+"\\b"))},b=function(a,b){a.className=a.className.replace(new RegExp("\\b"+b+"\\b")," ")},c=function(b,c){a(b,c)||(b.className+=" "+c)},d=[],e=4,f=0,g=function(){var a=document.querySelector(".ci-toolbar-ajax-requests");if(a){a.textContent="("+d.length+")",a.className="ci-toolbar-ajax-requests";var g=document.querySelector(".ci-toolbar-ajax-info");g&&(g.textContent=d.length+" AJAX request"+(d.length>1?"s":""));var h=document.querySelector(".ci-toolbar-block-ajax");d.length?c(h.parentNode,"active"):b(h.parentNode,"active"),f>0?c(h,"ci-ajax-request-loading"):e<4?(c(h,"ci-toolbar-status-red"),b(h,"ci-ajax-request-loading")):(b(h,"ci-ajax-request-loading"),b(h,"ci-toolbar-status-red"))}},h=function(a){var b=d[a];f++;var c=document.createElement("tr");b.DOMNode=c;var e=document.querySelector(".ci-toolbar-ajax-request-list");if(e){var h=document.createElement("td");h.textContent=b.method,c.appendChild(h);var i=document.createElement("td"),j=document.createElement("span");j.textContent="-",i.appendChild(j),c.appendChild(i);var k=document.createElement("td");if(k.className="ci-ajax-request-url","GET"===b.method){var l=document.createElement("a");l.setAttribute("href",b.url),l.setAttribute("target","_blank"),l.textContent=b.url.split("?")[0],k.appendChild(l)}else k.textContent=b.url;k.setAttribute("title",b.url),c.appendChild(k);var m=document.createElement("td");m.className="ci-ajax-request-duration",m.textContent="-",c.appendChild(m);var n=document.createElement("td");n.className="ci-ajax-profiler-url",""!=b.profiler&&(profilerLink.textContent="profiler",n.appendChild(n)),c.appendChild(n),c.className="ci-ajax-request ci-ajax-request-loading",e.insertBefore(c,e.firstChild),g()}},i=function(a){var b=d[a];f--;var c=b.DOMNode,h=c.children[0],i=c.children[1],j=i.children[0],k=c.children[3],l=c.children[4];if(b.error?(c.className="ci-ajax-request ci-ajax-request-error",h.className="ci-ajax-request-error",e=0):(c.className="ci-ajax-request ci-ajax-request-ok",e++),b.statusCode&&(b.statusCode<300?j.setAttribute("class","ci-toolbar-status"):b.statusCode<400?j.setAttribute("class","ci-toolbar-status ci-toolbar-status-yellow"):j.setAttribute("class","ci-toolbar-status ci-toolbar-status-red"),j.textContent=b.statusCode),b.duration&&(k.textContent=b.duration+"ms"),b.profiler){var m=document.createElement("a");m.setAttribute("href",cidvl_siteurl + "develbarprofiler/profil/"+b.profiler),m.setAttribute("target","_blank"),m.textContent="profiler",l.appendChild(m)}g()};if(j="addEventListener"in document.createElement("div")?function(a,b,c){a.addEventListener(b,c,!1)}:function(a,b,c){a.attachEvent("on"+b,c)},window.fetch&&void 0===window.fetch.polyfill){var l=window.fetch;window.fetch=function(){var a=l.apply(this,arguments),b=arguments[0],c=arguments[1];"[object Request]"===Object.prototype.toString.call(arguments[0])&&(b=arguments[0].url,c={method:arguments[0].method,credentials:arguments[0].credentials,headers:arguments[0].headers,mode:arguments[0].mode,redirect:arguments[0].redirect});var f="GET";c&&void 0!==c.method&&(f=c.method);var g={error:!1,url:b,method:f,type:"fetch",start:new Date},j=d.push(g)-1;return a.then(function(a){g.duration=new Date-g.start,g.error=a.status<200||a.status>=400,g.statusCode=a.status,i(j)},function(a){g.error=!0}),h(j),a}}if(window.XMLHttpRequest&&XMLHttpRequest.prototype.addEventListener){var m=XMLHttpRequest.prototype.open,n=0;XMLHttpRequest.prototype.open=function(a,b,c,e,f){var g=this,j={error:!1,url:b,method:a,profiler:"",start:new Date};n=d.push(j)-1,this.addEventListener("readystatechange",function(){4==g.readyState&&(j.duration=new Date-j.start,j.error=g.status<200||g.status>=400,j.statusCode=g.status,j.profiler=g.getResponseHeader("X-CI-Toolbar-Profiler"),i(n))},!1),h(n),m.apply(this,Array.prototype.slice.call(arguments))}}return{hasClass:a,removeClass:b,addClass:c,addEventListener:j,renderAjaxRequests:g}}(),CIjs.addEventListener(window,"load",function(){CIjs.renderAjaxRequests()});
var HideDevelBar=function(){var a=document.getElementById("develbar-container"),b=document.getElementById("develbar-off");a.style.display="none",b.style.display="block"},ShowDevelBar=function(){var a=document.getElementById("develbar-container"),b=document.getElementById("develbar-off");b.style.display="none",a.style.display="block"},HideDevelBarSection=function(){for(var a=document.getElementById("develbar-container"),b=a.getElementsByTagName("li"),c=0;c<b.length;c++)b[c].className=""},ShowViewVars=function(a){for(var b=a.parentElement.parentElement.nextSibling,c=document.getElementsByClassName("develbar-detail-vars"),d=0;d<c.length;d++)if(b!=c[d]){c[d].style.display="none";for(var e=document.getElementsByClassName("develbar-open-icon"),d=0;d<e.length;d++)e[d].innerHTML="+"}var f=b.style.display;"block"==f?b.style.display="none":(b.style.display="block",a.getElementsByClassName("develbar-open-icon")[0].innerHTML="-")};
\ No newline at end of file
<?php defined('BASEPATH') or die('No direct script access.');
/*
|--------------------------------------------------------------------------
| Developer's Toolbar
|--------------------------------------------------------------------------
|
| This option allows you to enable the developer's Toolbar
|
*/
$config['enable_develbar'] = TRUE;
/*
|--------------------------------------------------------------------------
| Check for update
|--------------------------------------------------------------------------
|
| This option allows you to check if there is any new version for CodeIgniter
| if this option is set to TRUE, it will slow down the page loading
|
*/
$config['check_update'] = FALSE;
$config['profiler_key_expiration_time'] = 1800; // sec
$config['documentation_link'] = 'http://www.codeigniter.com/userguide3/';
$config['ci_website'] = 'http://www.codeigniter.com';
$config['ci_download_link'] = 'http://www.codeigniter.com/download';
$config['ci_update_uri'] = 'https://raw.githubusercontent.com/bcit-ci/CodeIgniter/develop/system/core/CodeIgniter.php';
$config['develbar_update_uri'] = 'https://raw.githubusercontent.com/JCSama/CodeIgniter-develbar/master/version.json';
$config['develbar_download_link'] = 'https://github.com/JCSama/CodeIgniter-develbar';
/*
|--------------------------------------------------------------------------
| Debug Sections
|--------------------------------------------------------------------------
|
| This option allows you to enable specific sections into the Developer's Toolbar
|
*/
$config['develbar_sections'] = array(
'Benchmarks' => TRUE,
'Memory Usage' => TRUE,
'Request' => TRUE,
'Database' => TRUE,
'Hooks' => TRUE,
'Ajax' => TRUE,
'Libraries' => TRUE,
'Helpers' => TRUE,
'Views' => TRUE,
'Config' => TRUE,
'Session' => TRUE,
'Models' => TRUE,
);
\ No newline at end of file
<?php defined('BASEPATH') OR exit('No direct script access allowed');
// ------------------------------------------------------------------------
if (!function_exists('image_base64_encode')) {
function image_base64_encode($image)
{
$type = pathinfo($image, PATHINFO_EXTENSION);
$data = file_get_contents($image);
return 'data:image/' . $type . ';base64,' . base64_encode($data);
}
}
// ------------------------------------------------------------------------
if (!function_exists('check_ci_version')) {
function check_ci_version($url)
{
if(!$ci_version = file_get_contents($url)) {
return false;
}
$ci_version = htmlentities($ci_version);
preg_match("/CI_VERSION',\s'(.*)'\)/", $ci_version, $matches);
if(count($matches) && version_compare($matches[1], CI_VERSION, '>')) {
return $matches[1];
}
return FALSE;
}
}
// ------------------------------------------------------------------------
if (!function_exists('check_develbar_version')) {
function check_develbar_version($url)
{
if(!$develbar = file_get_contents($url))
return FALSE;
$develbar = json_decode($develbar, TRUE);
if(version_compare($develbar['version'], DevelBar::VERSION, '>')) {
return $develbar['version'];
}
return FALSE;
}
}
<?php
/**
* Class DevelBar
*
* This content is released under the MIT License (MIT)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @package DevelBar
* @author Mohamed ES-SAHLI
* @license http://opensource.org/licenses/MIT MIT License
* @link https://github.com/JCSama/CodeIgniter-develbar
* @since Version 0.1
* @filesource
*/
defined('BASEPATH') or die('No direct script access.');
class Develbar
{
/**
* DevelBar version
*/
const VERSION = '1.2';
/**
* Supported CI version
*/
const SUPPORTED_CI_VERSION = '2.2.0';
/**
* @var object
*/
private $CI;
/**
* @var string
*/
private $view_folder = 'develbar/';
/**
* @var string
*/
private $assets_folder = '';
/**
* @var array
*/
private $views = array();
/**
* List of helpers
*
* @var array
*/
private $helpers = array(
'utility',
'language',
'url',
'text'
);
/**
* @var array
*/
private $mimes = array(
'text/html'
);
/**
* List of profiler sections available
*/
private $default_options = array(
'enable_develbar' => false,
'check_update' => false,
'develbar_sections' => array(
'Benchmarks' => true,
'Memory Usage' => true,
'Request' => true,
'Database' => true,
'Hooks' => true,
'Models' => true,
'Libraries' => true,
'Helpers' => true,
'Views' => true,
'Config' => true,
'Session' => true,
'Ajax' => true,
),
);
/**
* DevelBar constructor.
*/
public function __construct()
{
$this->initialize();
}
/**
* Initialize DevelBar library
*/
private function initialize()
{
$this->CI =& get_instance();
$this->CI->load->config('develbar', true);
$this->CI->load->helpers($this->helpers);
// Initialize default options
$config = $this->CI->config->config['develbar'];
$this->default_options = array_merge($this->default_options, $config);
$this->assets_folder = APPPATH . 'third_party/DevelBar/assets/';
// Load lang file if exists
$this->load_lang_file();
log_message('debug', 'DevelBar Class Initialized !');
}
/**
* Load translation file for the default language,
* if the file does not exists, set english version as default
*
* @return void
*/
private function load_lang_file()
{
$default_language = $this->CI->config->config['language'];
$lang_file = APPPATH . 'third_party/DevelBar/language/' . $default_language . '/develbar_lang.php';
if (!file_exists($lang_file)) {
$default_language = 'english';
}
$this->CI->load->language('develbar', $default_language);
}
/**
* Start Debug Mode
*
* @return void
*/
public function debug()
{
if (version_compare(CI_VERSION, self::SUPPORTED_CI_VERSION, '<')) {
log_message('info',
sprintf($this->CI->lang->line('version_not_supported'), anchor($this->default_options['ci_website'])));
}
if ($this->CI->input->is_cli_request()) {
$this->CI->output->_display();
return;
}
if ($this->CI->input->is_ajax_request()) {
$this->debug_ajax_request();
return;
}
if ($this->default_options['enable_develbar'] == true && $this->CI->router->class != 'develbarprofiler'
&& in_array($this->CI->output->get_content_type(),
$this->mimes)
) {
if (version_compare(CI_VERSION, self::SUPPORTED_CI_VERSION, '<')) {
$this->default_options['check_update'] = true;
$this->views['not_supported'] = $this->CI->load->view($this->view_folder . 'not_supported',
array('config' => $this->default_options), true);
} else {
foreach ($this->default_options['develbar_sections'] as $section => $enabled) {
if ($enabled) {
$section = strtolower(str_replace(' ', '_', $section));
$this->views[$section] = call_user_func(array($this, $section . '_section'));
}
}
}
$output = $this->CI->output->get_output();
$develBarOutput = $this->develbar_output();
// Patch for Pace.js or similar
if (true == $this->default_options['develbar_sections']['Ajax']) {
$js = $this->CI->load->file($this->assets_folder.'js/ajax.js', true);
$js = '<script type="text/javascript">'.$js.'</script>';
$output = preg_replace('|<head>(.*?)<\/head>|is', '<head>'.$js.'$1</head>', $output, 1, $count);
if (!$count) {
$output = preg_replace(