Jump to content

Including modifiers when extending nodes: Difference between revisions

From NusaATK
Juneih (talk | contribs)
No edit summary
Juneih (talk | contribs)
No edit summary
Line 10: Line 10:


<span style="color: #000000; font-style: italic;">
<span style="color: #000000; font-style: italic;">


  function init()
  function init()
   {
   {
     $ret = parent::init();
     $ret = parent::init();
     $oldtype = $this->m_type;
     $oldtype = $this->m_type;
Line 39: Line 37:




So when you display the full image:
<ul>
<li>All the fields (master-detail) are retrieved from DB</li>
</ul>
<ul>
<li>Master key is stored in a session variable</li>
</ul>
<ul>
<li>A dynamic javascript function is created and:</li>
<ul>
<li>Create a position <em>draggable</em> <strong>DIV</strong> for any of the fields over the image</li>
</ul>
<ul>
<li>Attach a function to <em>double-click</em> event of <strong>Stampa</strong> image</li>
</ul>
</ul>
<p></p>
When you <em>double-click</em> on <strong>post-it</strong> image :
<ul>
<li>A new field is created</li>
</ul>
<ul>
<li>You can drag it all over the image</li>
</ul>
<ul>
<li>The new field is not stored on DB</li>
</ul>
<p></p>
When you <em>double-click</em> on <strong>stamp</strong> image:
<ul>
<li>You loop on all the field (<em>attention you loop on javascript DIV not on DB</em>)</li>
</ul>
<ul>
<li>For any of fields you call a <em>Ajax</em> updater function that fires Action <strong>ajaxupdate</strong> with proper parameters</li>
</ul>
<ul>
<li>ATK information like ATKstack, ATKLevel, ATKPreviouslevel are passed to <strong>Dispatch.php</strong> <em>ATK PHP file</em></li>
</ul>
<ul>
<li><em>Ajax</em> <em>work-in-progress</em> image is displayed</li>
</ul>
<ul>
<li>When <em>Ajax</em> function called is completed <em>work-in-progress</em> image is hided</li>
</ul>
<p></p>
Action <strong>ajaxupdate</strong> is called from <em>Ajax</em> and:
<ul>
<li>decodes field name, x position and y position (passed by GET parameters)</li>
</ul>
<ul>
<li>retrieves <strong>master-detail</strong> key <strong>id</strong> from <strong>reg_id</strong> <em>session variable</em></li>
</ul>
<ul>
<li>verify if detail record exists</li>
<ul>
<li>if yes call sql update to modify it</li>
</ul>
<ul>
<li>if no  call sql insert to create it</li>
</ul>
</ul>
<p></p>
<p></p>
<p></p>
<p></p>


--[[User:Saitta|Saitta]] 13:07, 10 November 2006 (CEST)
--[[User:Saitta|Saitta]] 13:07, 10 November 2006 (CEST)

Revision as of 15:28, 23 November 2006

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


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