Source for file Debugtoolbar.php

Documentation is available at Debugtoolbar.php

  1. <?php
  2. // vim: foldmethod=marker
  3. /**
  4.  *  Ethna_Plugin_Filter_DebugToolbar.php
  5.  *
  6.  *  @author     Sotaro KARASAWA <sotaro.k@gmail.com>
  7.  *  @package    Ethna
  8.  */
  9.  
  10. /**
  11.  *  DebugToolbar Plugin Filter
  12.  *
  13.  *  @description    DebugToolbar plugin standard set
  14.  *  @author         Sotaro KARASAWA <sotaro.k@gmail.com>
  15.  *  @access         public
  16.  *  @package        Ethna
  17.  */
  18. {
  19.     var $version = '1.0.0 - $Id: 912d8a4702c148eb8a7a0fb8e2afa9efde156191 $';
  20.  
  21.     private $_type_mapping array(
  22.         VAR_TYPE_INT      => 'VAR_TYPE_INT',
  23.         VAR_TYPE_FLOAT    => 'VAR_TYPE_FLOAT',
  24.         VAR_TYPE_STRING   => 'VAR_TYPE_STRING',
  25.         VAR_TYPE_DATETIME => 'VAR_TYPE_DATETIME',
  26.         VAR_TYPE_BOOLEAN  => 'VAR_TYPE_BOOLEAN',
  27.         VAR_TYPE_FILE     => 'VAR_TYPE_FILE',
  28.     );
  29.  
  30.     private $_form_type_mapping array(
  31.         FORM_TYPE_TEXT     => 'FORM_TYPE_TEXT',
  32.         FORM_TYPE_PASSWORD => 'FORM_TYPE_PASSWORD',
  33.         FORM_TYPE_TEXTAREA => 'FORM_TYPE_TEXTAREA',
  34.         FORM_TYPE_SELECT   => 'FORM_TYPE_SELECT',
  35.         FORM_TYPE_RADIO    => 'FORM_TYPE_RADIO',
  36.         FORM_TYPE_CHECKBOX => 'FORM_TYPE_CHECKBOX',
  37.         FORM_TYPE_SUBMIT   => 'FORM_TYPE_SUBMIT',
  38.         FORM_TYPE_FILE     => 'FORM_TYPE_FILE',
  39.         FORM_TYPE_BUTTON   => 'FORM_TYPE_BUTTON',
  40.         FORM_TYPE_HIDDEN   => 'FORM_TYPE_HIDDEN',
  41.     );
  42.  
  43.     private $_stime;
  44.  
  45.     public function __destruct({
  46.     }
  47.  
  48.     public function preFilter()
  49.     {
  50.         $stime microtime(true);
  51.         $this->_stime $stime;
  52.     }
  53.  
  54.     /**
  55.      *  filter which will be executed at the end.
  56.      *
  57.      *  @access public
  58.      */
  59.     function postFilter()
  60.     {
  61.         if (!is_null($view $this->ctl->getView()) && !$view->has_default_header{
  62.             return null;
  63.         }
  64.  
  65.         $this->init();
  66.         $this->dumpInfo();
  67.         $this->dumpConfig();
  68.         $this->dumpActionForm();
  69.         $this->smartyDebug();
  70.  
  71.     }
  72.  
  73.     function init()
  74.     {
  75.         $url $this->ctl->getConfig()->get('url');
  76.         if (substr($url-1!= '/'{
  77.             $url .= '/';
  78.         }
  79.  
  80.         // {{{ CSS
  81.         echo '<style type="text/css">';
  82.         echo <<<EOF
  83.  
  84. .xdebug-var-dump {
  85.   background: #f0f0f0;
  86.   padding: 2px;
  87.   font-family: monospace;
  88.   line-height: 150%;
  89. }
  90.  
  91. /* ethna debug style
  92.  */
  93.  
  94. /*
  95. 0 => string 'EMERG' (length=5)
  96. 1 => string 'ALERT' (length=5)
  97. 2 => string 'CRIT' (length=4)
  98. 3 => string 'ERR' (length=3)
  99. 4 => string 'WARNING' (length=7)
  100. 5 => string 'NOTICE' (length=6)
  101. 6 => string 'INFO' (length=4)
  102. 7 => string 'DEBUG' (length=5)
  103. */
  104. .ethna-debug-pre
  105. {
  106.   line-height: 55%;
  107.   border: solid 2px #333;
  108.   padding: 8px;
  109.   margin: 10px;
  110. }
  111. .ethna-debug-pre-blink
  112. {
  113.   color: #f00;
  114. }
  115. .ethna-debug-title ,
  116. .ethna-debug-subtitle {
  117.   font-family: Verdana, "Hiragino Kaku Gothic Pro W3", "Meiryo" !important;
  118.   font-size: 18px;
  119.   font-weight: bold;
  120.   line-height: 2.6em;
  121. }
  122.  
  123. .ethna-debug {
  124.   font-family: Verdana !important;
  125.   position: fixed;
  126.   bottom: 0px;
  127.   left: 0px;
  128.   width: 100%;
  129.   max-height: 50%;
  130.   padding-top: 20px;
  131.   padding-bottom: 50px;
  132.   overflow: auto;
  133.   background: #ccc !important;
  134.   border-top: solid 3px #fff;
  135.   color: #333 !important;
  136.   display:none;
  137.   font-size: 12px;
  138.   opacity: 0.9;
  139. }
  140. .ethna-debug td,
  141. .ethna-debug th {
  142.   color: #333 !important;
  143. }
  144. .ethna-debug div {
  145.   padding-left: 20px;
  146. }
  147.  
  148. #ethna-debug-switch-outline {
  149.   background: #666;
  150.   color: #fff;
  151.   margin: 0;
  152.   padding: 0;
  153.   position: fixed;
  154.   bottom: 0px;
  155.   left: 0px;
  156.   font-size: 14px;
  157.   font-family: Verdana, "Hiragino Kaku Gothic Pro W3", "Meiryo" !important;
  158.   opacity: 0.8;
  159. }
  160. #ethna-debug-switch-outline li {
  161.   padding: 7px 10px 7px 22px;
  162.   margin: 0;
  163.   float:left;
  164.   list-style:none;
  165.   z-index: 1000;
  166. }
  167. li.ethna-debug-switch {
  168.   /* background-position: 2px 12px; */
  169.   background-position: 4px 50%;
  170.   background-repeat: no-repeat;
  171. }
  172. li.ethna-debug-switch:hover {
  173.   background-color: #fff !important;
  174.   color: #333 !important;
  175. }
  176.  
  177. li#ethna-debug-switch-EthnaClose {
  178.   background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAHdSURBVDjLpZNraxpBFIb3a0ggISmmNISWXmOboKihxpgUNGWNSpvaS6RpKL3Ry//Mh1wgf6PElaCyzq67O09nVjdVlJbSDy8Lw77PmfecMwZg/I/GDw3DCo8HCkZl/RlgGA0e3Yfv7+DbAfLrW+SXOvLTG+SHV/gPbuMZRnsyIDL/OASziMxkkKkUQTJJsLaGn8/iHz6nd+8mQv87Ahg2H9Th/BxZqxEkEgSrq/iVCvLsDK9awtvfxb2zjD2ARID+lVVlbabTgWYTv1rFL5fBUtHbbeTJCb3EQ3ovCnRC6xAgzJtOE+ztheYIEkqbFaS3vY2zuIj77AmtYYDusPy8/zuvunJkDKXM7tYWTiyGWFjAqeQnAD6+7ueNx/FLpRGAru7mcoj5ebqzszil7DggeF/DX1nBN82rzPqrzbRayIsLhJqMPT2N83Sdy2GApwFqRN7jFPL0tF+10cDd3MTZ2AjNUkGCoyO6y9cRxfQowFUbpufr1ct4ZoHg+Dg067zduTmEbq4yi/UkYidDe+kaTcP4ObJIajksPd/eyx3c+N2rvPbMDPbUFPZSLKzcGjKPrbJaDsu+dQO3msfZzeGY2TCvKGYQhdSYeeJjUt21dIcjXQ7U7Kv599f4j/oF55W4g/2e3b8AAAAASUVORK5CYII=");
  179.   background-position: center 3px;
  180.   border: none;
  181.   text-indent: -9999px;
  182. }
  183. li#ethna-debug-switch-Ethna {
  184.   padding-right: 4px;;
  185.   background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAABUSURBVHjaYvz//z8DKYCJgVSA34b/YPC+zO0/DLAQo40iJzECzWZkZMRqw4dyd5x++I8XIPuBZCdBPQ10FZFhiM8P1AmlQaiB5FBiISkhAQFAgAEA1FBb2xYZTGEAAAAASUVORK5CYII=");
  186.   /* background-image: url(../images/ethna-debug-switch-Ethna.png); */
  187. }
  188. #ethna-debug-switch-outline li.ethna-debug-switch:nth-of-type(2) {
  189.   padding: 7px 10px;
  190. }
  191. #ethna-debug-switch-Timer {
  192.   background-image: url("data:image/png;base64,");
  193. }
  194. #ethna-debug-switch-ActionForm {
  195.   background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAZdJREFUeNqcUz2LwkAQfdFFEAQRRU1zrXYWgiCineX1Xi+50srOwn8gtv4OewsR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mxLwIXsMtlqFtlPB1YsFmEpf0ZAcmJp7CrvdPksO5IibMhSCogJfcnXE8w3sFctQGwIYMQteLoNTJIjJCOSmBJ1Odz4HNGltQvh8UMd2uggSPKxGGb+7TTRECS1SHKmaQ5NAaah9DeWAJ4ZiRYBFKcP3QAvHvIitjgWp/UVYxDTarBG8Vj+o1BCArGJ87AKeLY2jdOsIBnMBpcYvlNs5fNdL0E9O4t6EF6ZLV4bKfuYGPDx3FvBu9z0+ZT/iuF5Bq6FCEbW4bHRifmkFBoNh9A3oIsMyMIyZ8PD6c0yyDiT3t9DSyZi134RzbhnT0zO9+P8JoEba/8YJM5ZvP4Zr4VHvn+M5Umam19q03CMB1Lmf3UGXabihd0EHz/Ojq5DL5WqJROJIUZROHzBqJs58Pp+v2Wy2vwDSGGo4HH71hgj/IfJCD9xut0q//wgwALyXGwTcoR6SAAAAAElFTkSuQmCC");
  199. }
  200. #ethna-debug-switch-Info {
  201.   background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAH2SURBVHjapFPPS1RRFP7uvfOQQnRsnGkR4iJkwEUFiZsBBXPllHshaJP0w6WgCP0HLURhxkD/gaBFigaSi+El0bJWYRQ0iWI9JycJdebNvNe5P971RbSaB9+99z3O953vnHseC8MQrTwJuTDG7Ifr+Yc9tE0R8oSs+bxD2CAUPmw8241iZXKmFiNA5PvJjvZibuCa09d7BfVGA4xznNUbKO99x5b7zqewxySy8o+AJPf39S7fGcmhfHCIn9XfOCUiJwGJy6kkAoR4XXqLo+qvSSliBW7cftRDmb88mBh3Pn7dR4XIEZFzAS70uf3iBQRBiNVXm9LJ1ffrS7vclDM1PppzvKNjlVlQsBACC3P3MD97l96FQs1voK3NweDATcf0CZFAPpXswKfyAWUTGpzbxioHQrs5qzeRyXTDNFnfAtnPshgxsj0z/1yfY2XIs2CKlrUCKgvjymYU+HR6wjp4UnxphLQTxmLu5EI1f675vrUpMbf4wgapHgjdF3mGHr4dK1CpHq992/eQSXWaerXIeQ9EzIGAd1iBGSzbxMLqZsmXuulLnbZpVsAQJYIggPtmW15jQU1xfJC6upLLY6NDaAZMTd95SbovTYotlVx4nvf3IMVHmbbireGck06nkUgkFPGk5uOH58F1t/8/yi39TK08fwQYAJFWzPPb9QZyAAAAAElFTkSuQmCC");
  202. }
  203. #ethna-debug-switch-SmartyDebug {
  204.   background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAJcSURBVHjabFJLT1NREJ7zuo8+eFRAqYoESi0aEgwJaqxRXBQTEzDGiAsNO7f+ALdsTPwFunHlygUbE6NBVBAXjUYN8rCgUIjIK1Sgpff23jOee6sJqJNZzDmZx/d9MyT3+jzsNkTCTJRFFQEQ+MfoX29EW9R28X1JdK0/XxKk7df/pwAJ1Vg4rkd7qXkY3aI3igpW0UZYSDVTGdxPc1CWPADoUuOAFmoAs66ipX/n60MMJngkSQjbydwrg+ReUijGAo3obKOb16taZ+ZyE1PDACzefD3RdEK6YC8/k84WocKfgIhOQdSliBbhnL4YfpWdvXHm5DoV7WPp8Pzi5VSq2938rPoCaD4HymUhay08YlRmMovZ2Tv9fUuxI3ZT9P3NvoX11ccT4+NcCEIIeLB90oQZzkaabIxMTn1Idq4oqKWSckfuZJKdm9NfJvXYLb2hn5oHFRz6WzhFhhqIkuyRXpV+AnCAmmL/RSN2WwnIwSeh1fdg1enWxPzYaE1T45oqUxpSBm/SgbaODln4bq+m3dw7WVyiIF2t9oJe3+M6pfjR5trowNOhSqGDFoDnL8PByMDxlkh+4q4i6W7PoLQVEiGtH8Vv94FQRxin2rsGnxxbWX4rOCwsNfZeSQH8ROl4mhJeXhy6W5MKvRegRerCH6cSo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zTZtsVhOwq+tfdMymZx2MAcOuPrmrSYKaDHRUbZjbIcA8sM6xQ9sADFP4xNf54/t21tnk9kKrG3qBdCLw20T//GCFbY9tj+sVf8KMAACOoVxz9PPRwAAAABJRU5ErkJggg==");
  208. }
  209.  
  210. #ethna-debug-timewindow {
  211. }
  212. #ethna-debug-logwindow {
  213. }
  214.  
  215. .ethna-debug-log {
  216.   margin: 0;
  217.   padding: 2px 10px;
  218.   color: #000;
  219. }
  220.  
  221. .ethna-debug-log-EMERG {
  222. }
  223. .ethna-debug-log-ALERM {
  224. }
  225. .ethna-debug-log-CRIT {
  226. }
  227. .ethna-debug-log-ERR {
  228.   background: #ffaaaa;
  229. }
  230. .ethna-debug-log-WARNING {
  231.   background: #ffaaaa;
  232. }
  233. .ethna-debug-log-NOTICE {
  234.   background: #ffcccc;
  235. }
  236. .ethna-debug-log-INFO {
  237.   background: #ccccff;
  238. }
  239. .ethna-debug-log-DEBUG {
  240.   background: #ccc;
  241. }
  242.  
  243. .ethna-debug-log-loglevel {
  244.   font-weight: bold;
  245. }
  246.  
  247. .ethna-debug-log-loglevel-EMERG {
  248.   color: #f00;
  249. }
  250. .ethna-debug-log-loglevel-ALERM {
  251.   color: #f00;
  252. }
  253. .ethna-debug-log-loglevel-CRIT {
  254.   color: #f00;
  255. }
  256. .ethna-debug-log-loglevel-ERR {
  257.   color: #f00;
  258. }
  259. .ethna-debug-log-loglevel-WARNING {
  260.   color: #f00;
  261. }
  262. .ethna-debug-log-loglevel-NOTICE {
  263.   color: #f66;
  264. }
  265. .ethna-debug-log-loglevel-INFO {
  266.   color: #00f;
  267. }
  268. .ethna-debug-log-loglevel-DEBUG {
  269. }
  270.  
  271. .ethna-debug-window {
  272.  
  273. }
  274.  
  275. .ethna-debug-table {
  276.   border-collapse: collapse;
  277.   border: solid 1px #333;
  278. }
  279. .ethna-debug-table th ,
  280. .ethna-debug-table td {
  281.   padding: 3px 5px;
  282.   border-collapse: collapse;
  283.   border: solid 1px #333;
  284.   font-size: 12px;
  285. }
  286. .ethna-debug-table th {
  287.   background: #9c9;
  288. }
  289. .ethna-debug-table td.e {
  290.   background: #aca;
  291. }
  292. EOF;
  293.         echo '</style>';
  294.         // }}}
  295.  
  296.         // {{{ load JavaScript
  297.         echo <<<EOL
  298. <script type="text/javascript" src="http://www.google.com/jsapi"></script>
  299. <script type="text/javascript">
  300.     google.load("jquery", "1.3");
  301. </script>
  302. EOL;
  303.         // }}}
  304.  
  305.         // {{{ jquery.cookie.plugin
  306.         echo <<<EOF
  307. <script type="text/javascript">
  308. /**
  309.  * Cookie plugin
  310.  *
  311.  * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
  312.  * Dual licensed under the MIT and GPL licenses:
  313.  * http://www.opensource.org/licenses/mit-license.php
  314.  * http://www.gnu.org/licenses/gpl.html
  315.  *
  316.  */
  317.  
  318. /**
  319.  * Create a cookie with the given name and value and other optional parameters.
  320.  *
  321.  * @example $.cookie('the_cookie', 'the_value');
  322.  * @desc Set the value of a cookie.
  323.  * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
  324.  * @desc Create a cookie with all available options.
  325.  * @example $.cookie('the_cookie', 'the_value');
  326.  * @desc Create a session cookie.
  327.  * @example $.cookie('the_cookie', null);
  328.  * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
  329.  *       used when the cookie was set.
  330.  *
  331.  * @param String name The name of the cookie.
  332.  * @param String value The value of the cookie.
  333.  * @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
  334.  * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
  335.  *                             If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
  336.  *                             If set to null or omitted, the cookie will be a session cookie and will not be retained
  337.  *                             when the the browser exits.
  338.  * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
  339.  * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
  340.  * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
  341.  *                        require a secure protocol (like HTTPS).
  342.  * @type undefined
  343.  *
  344.  * @name $.cookie
  345.  * @cat Plugins/Cookie
  346.  * @author Klaus Hartl/klaus.hartl@stilbuero.de
  347.  */
  348.  
  349. /**
  350.  * Get the value of a cookie with the given name.
  351.  *
  352.  * @example $.cookie('the_cookie');
  353.  * @desc Get the value of a cookie.
  354.  *
  355.  * @param String name The name of the cookie.
  356.  * @return The value of the cookie.
  357.  * @type String
  358.  *
  359.  * @name $.cookie
  360.  * @cat Plugins/Cookie
  361.  * @author Klaus Hartl/klaus.hartl@stilbuero.de
  362.  */
  363. jQuery.cookie = function(name, value, options) {
  364.     if (typeof value != 'undefined') { // name and value given, set cookie
  365.         options = options || {};
  366.         if (value === null) {
  367.             value = '';
  368.             options.expires = -1;
  369.         }
  370.         var expires = '';
  371.         if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
  372.             var date;
  373.             if (typeof options.expires == 'number') {
  374.                 date = new Date();
  375.                 date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
  376.             } else {
  377.                 date = options.expires;
  378.             }
  379.             expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
  380.         }
  381.         // CAUTION: Needed to parenthesize options.path and options.domain
  382.         // in the following expressions, otherwise they evaluate to undefined
  383.         // in the packed version for some reason...
  384.         var path = options.path ? '; path=' + (options.path) : '';
  385.         var domain = options.domain ? '; domain=' + (options.domain) : '';
  386.         var secure = options.secure ? '; secure' : '';
  387.         document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
  388.     } else { // only name given, get cookie
  389.         var cookieValue = null;
  390.         if (document.cookie && document.cookie != '') {
  391.             var cookies = document.cookie.split(';');
  392.             for (var i = 0; i < cookies.length; i++) {
  393.                 var cookie = jQuery.trim(cookies[i]);
  394.                 // Does this cookie string begin with the name we want?
  395.                 if (cookie.substring(0, name.length + 1) == (name + '=')) {
  396.                     cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
  397.                     break;
  398.                 }
  399.             }
  400.         }
  401.         return cookieValue;
  402.     }
  403. };
  404. </script>
  405. EOF;
  406.         // }}}
  407.  
  408.         // {{{ JavaScript for Debugtoolbar
  409.         echo <<<EOL
  410. <script type="text/javascript">
  411. //jQuery.noConflict();
  412. jQuery(function()
  413. {
  414.  
  415.     var buttonOutline = document.createElement('ul');
  416.     jQuery(buttonOutline).attr('id', 'ethna-debug-switch-outline');
  417.     jQuery('html > body').append(buttonOutline);
  418.  
  419.     var buttonEthna = document.createElement('li');
  420.     jQuery(buttonEthna).attr('id', 'ethna-debug-switch-Ethna');
  421.     jQuery(buttonEthna).attr('class', 'ethna-debug-switch');
  422.     jQuery(buttonEthna).text("Ethna");
  423.     jQuery(buttonOutline).append(buttonEthna);
  424.  
  425.     var state = {};
  426.  
  427.     jQuery('.ethna-debug').each(function()
  428.     {
  429.         var name = jQuery(this).children('div.ethna-debug-title').text();
  430.         //var stateName = ^
  431.  
  432.         var showMessage = ' ' + name;
  433.         var hideMessage = ' ' + name;
  434.         state[name] = false;
  435.  
  436.         var targetId = jQuery(this).attr('id');
  437.         var buttonId = 'ethna-debug-switch-' + name;
  438.         var button = document.createElement('li');
  439.         jQuery(button).attr('id', buttonId);
  440.         jQuery(button).attr('class', 'ethna-debug-switch');
  441.         jQuery(button).text(showMessage);
  442.  
  443.         jQuery(button).click(function()
  444.         {
  445.             jQuery('.ethna-debug').each(function()
  446.             {
  447.                 jQuery(this).hide();
  448.                 var local_name = jQuery(this).children('div.ethna-debug-title').text();
  449.  
  450.                 if (name != local_name) {
  451.                     state[local_name] = false;
  452.                     jQuery.cookie(local_name, 0);
  453.                 }
  454.             });
  455.  
  456.             if (!state[name]) {
  457.                 jQuery(this).text(hideMessage);
  458.                 //jQuery('#ethna-debug-logwindow').show();
  459.                 jQuery('#' + targetId).show();
  460.                 jQuery.cookie(name, 1);
  461.                 state[name] = true;
  462.             }
  463.             else {
  464.                 jQuery(this).text(showMessage);
  465.                 //jQuery('#ethna-debug-logwindow').hide();
  466.                 jQuery('#' + targetId).hide();
  467.                 jQuery.cookie(name, 0);
  468.                 state[name] = false;
  469.             }
  470.         });
  471.  
  472.  
  473.         jQuery(button).hover(function()
  474.         {
  475.             jQuery(this).css('cursor', 'pointer');
  476.         },
  477.         function()
  478.         {
  479.             jQuery(this).css('cursor', 'default');
  480.         });
  481.  
  482.         jQuery(buttonOutline).append(button);
  483.  
  484.         if (jQuery.cookie(name) == 1) {
  485.             jQuery('#' + targetId).show();
  486.             state[name] = true;
  487.         }
  488.  
  489.         // log window coloring
  490.         if(jQuery('#' + targetId)
  491.             .is(":has('.ethna-debug-log-EMERG,.ethna-debug-log-ALERM,.ethna-debug-log-CRIT,.ethna-debug-log-ERR,.ethna-debug-log-WARNING,.ethna-debug-log-NOTICE')"))
  492.         {
  493.             jQuery(button).css('background-color', "#f00")
  494.                 .css('color', "#fff");
  495.         }
  496.     });
  497.  
  498.  
  499.     // close button
  500.     var closeButtonEthna = document.createElement('li');
  501.     jQuery(closeButtonEthna).attr('id', 'ethna-debug-switch-EthnaClose');
  502.     jQuery(closeButtonEthna).attr('class', 'ethna-debug-switch');
  503.     jQuery(closeButtonEthna).text("close");
  504.     jQuery(closeButtonEthna).click(function(e) {
  505.         jQuery(buttonOutline).hide();
  506.         return false;
  507.     });
  508.     jQuery(buttonOutline).append(closeButtonEthna);
  509.  
  510. });
  511. </script>
  512. EOL;
  513.         // }}}
  514.  
  515.         // time
  516.         $etime microtime(true);
  517.         $time   sprintf("%.4f"$etime $this->_stime);
  518.  
  519.         echo '<div class="ethna-debug" id="ethna-debug-evwindow">';
  520.         echo '<div class="ethna-debug-title">' ETHNA_VERSION
  521.             . ': ' $this->controller->getCurrentActionName()  '</div>';
  522.         echo "<div class=\"ethna-debug-log\">";
  523.         echo ETHNA_VERSION;
  524.         echo "</div> \n";
  525.         echo "<div class=\"ethna-debug-log\">";
  526.         echo "Ethna_Plugin_Debugtoolbar Version" $this->version;
  527.         echo "</div> \n";
  528.  
  529.         $time_warning_class ="";
  530.         if (0.5 $time{
  531.             $time_warning_class =" ethna-debug-log-WARNING";
  532.         }
  533.         elseif ($time{
  534.             $time_warning_class =" ethna-debug-log-ERR";
  535.         }
  536.         echo '<div class="ethna-debug-subtitle">Time Elapsed</div>';
  537.         echo "<div class=\"ethna-debug-log $time_warning_class\">"${time} sec.";
  538.         echo "</div> \n";
  539.  
  540.         echo '<div class="ethna-debug-subtitle">Action/View/Forward</div>';
  541.         echo '<div id="ethna-debug-info-actionenv" style="">';
  542.         $info array(
  543.             'action' => $this->ctl->getCurrentActionName(),
  544.             'action_form' => get_class($this->ctl->getActionForm()),
  545.             'view' => get_class($this->ctl->getView()),
  546.             'forward' => (is_null($view $this->ctl->getView())) "" $view->getCurrentForwardName(),
  547.             'encoding' => $this->controller->getClientEncoding(),
  548.         );
  549.         self::dumpArray($info);
  550.         echo "</div> \n";
  551.         echo '</div>';
  552.     }
  553.  
  554.     /**
  555.      * dump php info
  556.      *
  557.      * @access  public
  558.      */
  559.     function dumpInfo()
  560.     {
  561.         echo '<div class="ethna-debug" id="ethna-debug-infowindow">';
  562.         echo '<div class="ethna-debug-title">Info</div>';
  563.         echo "<div class=\"ethna-debug-log\">";
  564.  
  565.         echo '<div class="ethna-debug-subtitle">PHPINFO</div>';
  566.         echo '<div class="ethna-debug-subtitle" id="ethna-debug-info-env-title"><a href="javascript:;">Environment &gt;&gt;</a></div>';
  567.         echo '<div id="ethna-debug-info-env" style="display:none;">';
  568.         echo $this->parsePHPInfo(INFO_ENVIRONMENT);
  569.         echo "</div> \n";
  570.  
  571.         echo '<div class="ethna-debug-subtitle" id="ethna-debug-info-var-title"><a href="javascript:;">Variables &gt;&gt;</a></div>';
  572.         echo '<div id="ethna-debug-info-var" style="display:none;">';
  573.         echo $this->parsePHPInfo(INFO_VARIABLES);
  574.         echo "</div> \n";
  575.  
  576.         echo '<div class="ethna-debug-subtitle" id="ethna-debug-info-modules-title"><a href="javascript:;">Installed Modules &gt;&gt;</a></div>';
  577.         echo '<div id="ethna-debug-info-modules" style="display:none;">';
  578.         echo $this->parsePHPInfo(INFO_MODULES);
  579.         //$this->dumpArray(get_loaded_extensions());
  580.         echo "</div> \n";
  581.  
  582.         echo <<<EOF
  583. <script type="text/javascript">
  584. jQuery(function()
  585. {
  586.     jQuery("#ethna-debug-info-env-title a").click(function() {
  587.         jQuery("#ethna-debug-info-env").toggle();
  588.     });
  589.     jQuery("#ethna-debug-info-var-title a").click(function() {
  590.         jQuery("#ethna-debug-info-var").toggle();
  591.     });
  592.     jQuery("#ethna-debug-info-modules-title a").click(function() {
  593.         jQuery("#ethna-debug-info-modules").toggle();
  594.     });
  595. });
  596. </script>
  597. EOF;
  598.  
  599.         echo "</div> \n";
  600.         echo '</div>';
  601.  
  602.     }
  603.  
  604.  
  605.     function parsePHPInfo($info)
  606.     {
  607.         ob_start();
  608.         $phpinfo phpinfo($info);
  609.         $info ob_get_contents();
  610.         ob_end_clean();
  611.  
  612.         $dom new DOMDocument();
  613.         $dom->loadHTML($info);
  614.         $info_html @simplexml_import_dom($dom);
  615.         $body $info_html->xpath("//body");
  616.         return preg_replace("/<table/""<table class=\"ethna-debug-table ethna-debug-table-info\""$body[0]->asXML());
  617.     }
  618.  
  619.     /**
  620.      * dump action form defined values and posted values
  621.      *
  622.      * @access  public
  623.      */
  624.     function dumpActionForm()
  625.     {
  626.         $af $this->ctl->getActionForm();
  627.         if ($af === null{
  628.             return ;
  629.         }
  630.         echo '<div class="ethna-debug" id="ethna-debug-afwindow">';
  631.         echo '<div class="ethna-debug-title">ActionForm</div>';
  632.  
  633.         echo '<div class="ethna-debug-subtitle">Posted Value</div>';
  634.         echo "<div class=\"ethna-debug-log\">";
  635.         $action_form_array $this->ctl->getActionForm()->getArray();
  636.         self::dumpArray($action_form_array);
  637.         echo "</div> \n";
  638.  
  639.         echo '<div class="ethna-debug-subtitle">Definition</div>';
  640.         echo "<div class=\"ethna-debug-log\">";
  641.         $action_form_def $this->controller->getActionForm()->getDef();
  642.         self::dumpArray($action_form_def);
  643.         echo "</div> \n";
  644.  
  645.         echo '<div class="ethna-debug-subtitle">App</div>';
  646.         echo "<div class=\"ethna-debug-log\">";
  647.         $app_vars $this->controller->getActionForm()->getAppArray();
  648.         self::dumpArray($app_vars);
  649.         echo "</div> \n";
  650.  
  651.         echo '<div class="ethna-debug-subtitle">AppNe</div>';
  652.         echo "<div class=\"ethna-debug-log\">";
  653.         $app_ne_vars $this->controller->getActionForm()->getAppNEArray();
  654.         self::dumpArray($app_ne_vars);
  655.         echo "</div> \n";
  656.  
  657.         echo '<div class="ethna-debug-subtitle">$_GET</div>';
  658.         echo "<div class=\"ethna-debug-log\">";
  659.         self::dumpArray($_GET);
  660.         echo "</div> \n";
  661.  
  662.         echo '<div class="ethna-debug-subtitle">$_POST</div>';
  663.         echo "<div class=\"ethna-debug-log\">";
  664.         self::dumpArray($_POST);
  665.         echo "</div> \n";
  666.  
  667.         echo '</div>';
  668.     }
  669.  
  670.     function dumpConfig()
  671.     {
  672.         $config $this->controller->getConfig();
  673.         echo '<div class="ethna-debug" id="ethna-debug-configwindow">';
  674.         echo '<div class="ethna-debug-title">Config</div>';
  675.         echo "<div class=\"ethna-debug-log\">";
  676.         //var_dump($this->controller->action_form->getArray());
  677.         self::dumpArray($config->config);
  678.         echo "</div> \n";
  679.         echo '</div>';
  680.     }
  681.  
  682.     function smartyDebug()
  683.     {
  684.         if (!defined('Smarty::SMARTY_VERSION')) {
  685.             return ;
  686.         }
  687.         $c Ethna_Controller::getInstance();
  688.         $debug_tpl $c->getDirectory('template'"/smarty_debug.tpl";
  689.  
  690.         //if smarty2
  691.         //if (!file_exists($debug_tpl)) {
  692.         //    Ethna::raiseWarning(sprintf("Smarty debug template not found, please set %s.", $debug_tpl), E_USER_WARNING);
  693.         //    return null;
  694.         //}
  695.  
  696.         require_once SMARTY_SYSPLUGINS_DIR 'smarty_internal_debug.php';
  697.  
  698.         // get template directory
  699.         $r $c->getRenderer();
  700.         $smarty $r->getEngine();
  701.  
  702.         $vars Smarty_Internal_Debug::get_debug_vars($smarty);
  703.  
  704.         //$smarty_original_debugging = $smarty->debugging;
  705.         //$smarty_original_debugtpl = $smarty->debug_tpl;
  706.  
  707.         //$smarty->debugging = true;
  708.         //$smarty->debug_tpl = $debug_tpl;
  709.         //$smarty->assign('_smarty_debug_output', 'html');
  710.  
  711.         echo '<div class="ethna-debug" id="ethna-debug-smartydebugwindow">';
  712.         echo '<div class="ethna-debug-title">SmartyDebug</div>';
  713.  
  714.         echo '<div class="ethna-debug-subtitle">Smarty template vars</div>';
  715.         echo "<div class=\"ethna-debug-log\">";
  716.         foreach ($vars->tpl_vars as $k => $v{
  717.             $v array($k => $v->value);
  718.             self::dumpArray($v);
  719.         }
  720.         echo "</div> \n";
  721.  
  722.         echo '<div class="ethna-debug-subtitle">Smarty config vars</div>';
  723.         echo "<div class=\"ethna-debug-log\">";
  724.         foreach ($vars->config_vars as $k => $v{
  725.             $v array($k => $v->value);
  726.             self::dumpArray($v);
  727.             //self::dumpArray($v->value);
  728.         }
  729.         echo "</div> \n";
  730.  
  731.         echo "</div> \n";
  732.         echo '</div>';
  733.  
  734.         //$smarty->debugging = $smarty_original_debugging;
  735.         //$smarty->debug_tpl = $smarty_original_debugtpl;
  736.     }
  737.  
  738.     public static function dumpArray(&$array)
  739.     {
  740.         echo "<table class=\"ethna-debug-table\">";
  741.         foreach ($array as $k => $v{
  742.             echo "<tr>\n";
  743.             echo "<th>{$k}</th>";
  744.             if (is_array($v)) {
  745.                 echo "<td>";
  746.                 self::dumpArray($v);
  747.                 echo "</td>";
  748.             }
  749.             elseif (is_bool($v)) {
  750.                 echo "<td>" ($v '<span style="color: #090;">true</span>' '<span style="color: #900;">false</span>')  "</td>";
  751.             }
  752.             elseif (is_null($array)) {
  753.                 echo "<td>NULL</td>";
  754.             }
  755.             elseif (is_scalar($v)) {
  756.                 // form type mapping check
  757.                 $key '_' $k '_mapping';
  758.                 $ar = isset(self::$keyself::$key array();
  759.                 if (($k === 'type' || $k === 'form_type')
  760.                     && isset($ar[$v]))
  761.                 {
  762.                     echo "<td>";
  763.                     if ($v === null{
  764.                         echo "Undefined";
  765.                     else {
  766.                         echo $ar[$v];
  767.                     }
  768.                     echo "</td>";
  769.                 }
  770.                 else {
  771.                     echo "<td>{$v}</td>";
  772.                 }
  773.             }
  774.             elseif (is_object($v)) {
  775.                 echo "<td>(Object) " get_class($v"</td>";
  776.             }
  777.             else {
  778.                 echo "<td>" gettype($v"</td>";
  779.             }
  780.             echo "</tr>\n";
  781.         }
  782.         echo "</table>\n";
  783.     }
  784.  
  785. }

Documentation generated on Fri, 11 Nov 2011 03:58:00 +0900 by phpDocumentor 1.4.3