Jump to content

Debughelper Firefox Add-on: Difference between revisions

From NusaATK
No edit summary
The Extention
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 plugin to switch between debuglevels by just clicking the atkdebughelper-icon.
But now there's option 3 :) I created a firefox extention to switch between debuglevels by just clicking the atkdebughelper-icon.


= Using the ATK debughelper =
= Using the ATK debughelper =
== The Extention ==
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 ==
== 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).
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).

Revision as of 16:01, 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 extention to switch between debuglevels by just clicking the atkdebughelper-icon.

Using the ATK debughelper

The Extention

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;
   }

Developers

Howto implement your feature

I'm sure there will be some feature requests. You can send them to me: jeroenvs@ibuildings.nl, or you can implement them yourself.

  • Location in SVN: http://svn.ibuildings.nl/ibuildings/jeroenvs/atkdebughelper
  • Make your changes
  • Raise the 'em:version' in /install.rdf
  • Add some info in /changelog.txt
  • Create a new .xpi file:
    • Select all extension files (EXCEPT the .xpi-file) and dirs in the root: changelog.txt, chrome/, chrome.manifest, defaults/ and install.rdf
    • Zip them
    • Change the extension to .xpi (make sure it's not a .zip-file anymore)
    • Overwrite the one in the root
  • And commit it!

Useful info

Some useful sites for developers: