Jump to content

Debughelper Firefox Add-on: Difference between revisions

From NusaATK
moved dev-section to private (since project is in private SVN)
No edit summary
Line 7: Line 7:
If you use the second option in ATK applications, you'll end up at the indexpage after confirming the URL..
If you use the second option in ATK applications, you'll end up at the indexpage after confirming the URL..


But now there's option 3 :) I created a firefox extention to switch between debuglevels by just clicking the atkdebughelper-icon.
But now there's option 3 :) I created a firefox add-on to switch between debuglevels by just clicking the atkdebughelper-icon.


= Using the ATK debughelper =
= Using the ATK debughelper =
== The Extention ==
== The Add-on ==
I'll place the XPI on a nice place later, for now: [[Media:Atkdebughelper.xpi.zip]]
I'll place the XPI on a nice place later, for now: [[Media:Atkdebughelper.xpi.zip]]
* Unzip it
* Unzip it

Revision as of 16:43, 17 June 2009

Introduction

In my latest ATK project, I needed to switch quite often between debuglevel 1 and 2: in some cases I wanted to see the intermediate-screens after updating a record, but not everytime.

To do this, we have 2 options:

  1. change $config_debug value in your config.inc.php, or
  2. add debug-key and -level to your URL if smart-debugging is enabled.

If you use the second option in ATK applications, you'll end up at the indexpage after confirming the URL..

But now there's option 3 :) I created a firefox add-on to switch between debuglevels by just clicking the atkdebughelper-icon.

Using the ATK debughelper

The Add-on

I'll place the XPI on a nice place later, for now: Media:Atkdebughelper.xpi.zip

  • Unzip it
  • Drag the XPI-file to your FireFox addons

Howto

First of all, you need the latest ATK version, which contains some additional checking for debug-keys and levels. If you don't have the latest version, or do not want to update (existing/old projects), you can make a local change yourself (see "Local ATK changes" below).

Then:
1. Make sure you enabled smart debugging in your project's config.inc.php (replace 'yourdebugkey' by your specific project-key):

$config_smart_debug[] = array("type"=>"request", "key"=>"yourdebugkey");

2. Add the domain name and key for your sites in the 'Site debug keys' (ATK debughelper preferences) to automatically enable debugging for that site

e.g. URL 1: http://www.achievo.org  KEY 1: yourdebugkey

3. Press the ATK debughelper icon to change the debuglevel.

Troubleshooting

Clicking icon doesn't change application's debuglevel:

  • Is smart debugging enabled in your config.inc.php?
  • Did you set the domain-name and debug-key correctly in the 'Site debug keys' above?
  • Do NOT use atkdebug[key] and atkdebug[level] in your URL, they overrule the ATK debughelper.
  • Is your atk/class.atkconfig.inc up to date?
  • Check if ATKDEBUG_LEVEL and ATKDEBUG_KEY cookies are present.

Tricks

If you don't want to add the debug url/keys to the ATK debughelper-settings, you can also enable debugging the old way by adding &atkdebug[key]=yourdebugkey to the URL. After this, you can switch the debuglevel by pressing the icon.

Local ATK changes

Changes in atk/class.atkconfig.inc needed for this plugin to work (already present in latest ATK version in SVN).

   function requestDebugEnabled($params)
   {
     $session = &atkSessionManager::getSession();

     if (isset($_REQUEST["atkdebug"]["key"]))
     {
       $session["debug"]["key"] = $_REQUEST["atkdebug"]["key"];
     }
     else if (isset($_COOKIE['ATKDEBUG_KEY']) && !empty($_COOKIE['ATKDEBUG_KEY']))
     {
       $session["debug"]["key"] = $_COOKIE['ATKDEBUG_KEY'];
     }
     
     return (isset($session["debug"]["key"]) && $session["debug"]["key"] == $params["key"]);
   }
   function smartDebugLevel($default, $options=array())
   {
     $session = &atkSessionManager::getSession();

     $enabled = $default > 0;

     foreach ($options as $option)
     {
       $method = $option["type"]."DebugEnabled";
       if (is_callable(array("atkconfig", $method)))
         $enabled = $enabled || atkconfig::$method($option);
     }

     if ($enabled)
     {
       if (isset($_REQUEST["atkdebug"]["level"]))
       {
         $session["debug"]["level"] = $_REQUEST["atkdebug"]["level"];
       }
       else if (isset($_COOKIE['ATKDEBUG_LEVEL']))
       {
         $session["debug"]["level"] = $_COOKIE['ATKDEBUG_LEVEL'];
       }
       
       if (isset($session["debug"]["level"]))
         return $session["debug"]["level"];
       else return max($default, 1);
     }

     return $default;
   }