Jump to content

Including modifiers when extending nodes

From NusaATK
Revision as of 15:27, 23 November 2006 by Juneih (talk | contribs)

ATK Howto: Including modifiers when extending nodes

Complexity: easy
Author: June Henriksen <juneih@linpro.no>

List of other Howto's

This howto explains how you can include modifiers when you extend a node.

All modifiers added to a node will be run in the node's init function. Which modifiers that runs however, depends on the m_type of a node, which will be different for any node that extends it. In order to have the modifiers run, some changes has to be made in the extended nodes init node.

An example init_node:


function init()
 {
   $ret = parent::init();
   $oldtype = $this->m_type;
   $oldmodule= $this->m_module;
   $this->m_type='hours';
   $this->m_module='timereg';
   global $g_modifiers;
   if (isset($g_modifiers[$this->atknodetype()]))
   {
     foreach ($g_modifiers[$this->atknodetype()] as $modulename)
     {
       $module = &getModule($modulename);
       $module->modifier($this);
     }
   }
   $this->m_module=$oldmodule;
   $this->m_type = $oldtype;
   return $ret;
 }


So when you display the full image:

  • All the fields (master-detail) are retrieved from DB
  • Master key is stored in a session variable
  • A dynamic javascript function is created and:
    • Create a position draggable DIV for any of the fields over the image
    • Attach a function to double-click event of Stampa image

When you double-click on post-it image :

  • A new field is created
  • You can drag it all over the image
  • The new field is not stored on DB

When you double-click on stamp image:

  • You loop on all the field (attention you loop on javascript DIV not on DB)
  • For any of fields you call a Ajax updater function that fires Action ajaxupdate with proper parameters
  • ATK information like ATKstack, ATKLevel, ATKPreviouslevel are passed to Dispatch.php ATK PHP file
  • Ajax work-in-progress image is displayed
  • When Ajax function called is completed work-in-progress image is hided

Action ajaxupdate is called from Ajax and:

  • decodes field name, x position and y position (passed by GET parameters)
  • retrieves master-detail key id from reg_id session variable
  • verify if detail record exists
    • if yes call sql update to modify it
    • if no call sql insert to create it

--Saitta 13:07, 10 November 2006 (CEST)