/[cvs]/nfo/php/libs/org.netfrag.app/WebExplorer/MVC.php
ViewVC logotype

Diff of /nfo/php/libs/org.netfrag.app/WebExplorer/MVC.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by jonen, Thu Mar 20 07:54:52 2003 UTC revision 1.15 by jonen, Sat May 10 18:19:55 2003 UTC
# Line 4  Line 4 
4   * $Id$   * $Id$
5   *   *
6   * $Log$   * $Log$
7     * Revision 1.15  2003/05/10 18:19:55  jonen
8     * + added stuff relating to 'create/add new' links/buttons
9     *
10     * Revision 1.14  2003/04/19 16:20:47  jonen
11     * + added handle of ecom 'UMnav' according to page 'Benutzverwaltung'
12     *
13     * Revision 1.13  2003/04/18 15:30:24  joko
14     * NEW: parameter 'ecom_data_filter' - used for 'items'
15     *   (introduced to filter xml-payload at backend side via xpath queries)
16     * documented global state parameters
17     * some comments
18     *
19     * Revision 1.12  2003/04/18 13:40:54  jonen
20     * + added 'topic' to requested vars which will currently be merged with the 'ap' var
21     *
22     * Revision 1.11  2003/04/11 00:51:10  joko
23     * minor update: just testing stuff...
24     *
25     * Revision 1.10  2003/04/10 06:03:26  joko
26     * ++ renamed keys: 'ecom_data_form_edit', 'ecom_data_form_cancel' through 'ecom_data_action_edit', 'ecom_data_action_cancel'
27     * + new key: 'ecom_data_action_delete'
28     * + Action.Delete: not really, since it's inside component in fact (self-contained ecom)
29     *
30     * Revision 1.9  2003/04/09 00:05:50  jonen
31     * added request values and functions needed for extended form handling
32     *
33     * Revision 1.8  2003/04/08 17:53:08  joko
34     * NEW: Module 'RemoteAction' in 'phase_startup'
35     *
36     * Revision 1.7  2003/04/07 22:32:27  jonen
37     * + minor changes related to new ecom 'chooser'
38     *
39     * Revision 1.6  2003/04/06 01:32:57  jonen
40     * + minor changes
41     *
42     * Revision 1.5  2003/04/05 21:18:29  joko
43     * added Chooser and associated 'ecds'-parameter
44     * new rule (at bottom) to dispatch datasource-keys to each ecom-component
45     *
46     * Revision 1.4  2003/04/04 23:59:19  jonen
47     * + minor changes according to data form submits
48     *
49     * Revision 1.3  2003/04/04 01:28:13  jonen
50     * + added function to purge unwanted merged vars
51     * + handle form submit's now
52     *
53   * Revision 1.2  2003/03/20 07:54:52  jonen   * Revision 1.2  2003/03/20 07:54:52  jonen
54   * + added docu   * + added docu
55   *   *
# Line 64  class WebExplorer_MVC extends Site_WebAp Line 110  class WebExplorer_MVC extends Site_WebAp
110    
111      $this->add_model( array(      $this->add_model( array(
112        //args => array( 'classname', 'guid', 'action', 'data_locator_key', 'block' ),        //args => array( 'classname', 'guid', 'action', 'data_locator_key', 'block' ),
113        request_args => array( 'ap', 'ecom_label', 'ecom_type', 'ecom_abstract_type', 'ecom_action', 'ecom_data_locator_key',        request_args => array(
114                                           'ecom_data_ident', 'ecom_data_meta' ),          // ApplicationTopic
115            'topic',
116            // ApplicationPage
117            'ap',
118            // important/required parameters for valid ecom-components
119            'ecom_label', 'ecom_type', 'ecom_abstract_type', 'ecom_mode',
120            // parameters about data identifiers, locations, sources and associated meta-information
121            'ecom_data_locator_key',
122            'ecom_data_ident',
123            'ecom_data_meta', 'ecom_data_meta_x',
124            'ecom_data_action_edit', 'ecom_data_action_cancel', 'ecom_data_action_delete', 'ecom_data_action_create',
125            'ecom_data_form_checkbox', 'ecom_data_form_action',
126            'ecom_data_source_key',
127            'ecom_data_filter',
128          ),
129        request_arg => array(        request_arg => array(
130          'ap' => array( query_arg => 'ap' ),          
131          'ecom_label' => array( query_arg => 'ecl' ),          // a key identifying the current topic
132          'ecom_type' => array( query_arg => 'ect' ),            'topic' => array( query_arg => 't' ),
133          'ecom_abstract_type' => array( query_arg => 'ecat' ),  
134          'ecom_action' => array( query_arg => 'ecac' ),          // a key identifying the current page
135          'ecom_data_locator_key' => array( query_arg => 'ecdlk' ),            'ap' => array( query_arg => 'ap' ),
136          'ecom_data_ident' => array( query_arg => 'ecdid' ),          
137          'ecom_data_meta' => array( query_arg => 'ecdm' ),          // ecom, ecom, ecom
138              
139              // component specific arguments (important for the main dispatcher, etc.)
140              // a label identifying a component
141              'ecom_label' => array( query_arg => 'ecl' ),
142              // data or schema
143              'ecom_type' => array( query_arg => 'ect' ),
144              // item, list or tree
145              'ecom_abstract_type' => array( query_arg => 'ecat' ),
146    
147    
148            // data, data, data
149              
150              // e.g. view, edit
151              'ecom_mode' => array( query_arg => 'ecmod' ),
152              // This should be renamed to 'ecom_data_transport_key'.
153              'ecom_data_locator_key' => array( query_arg => 'ecdlk' ),
154              
155              // This should be enough to identify data Xyz.
156              // e.g. an OID, a GUID, a filename or similar stuff
157              'ecom_data_ident' => array( query_arg => 'ecdid' ),
158              // e.g. a classname or a filename
159              'ecom_data_meta' => array( query_arg => 'ecdm' ),
160              // extended meta, e.g. 2nd parent identifier
161              'ecom_data_meta_x' => array( query_arg => 'ecdmx' ),
162              // filter the data: e.g.
163              //    - an xpath-query (xpq),
164              //    - an abstract/custom filter string or
165              //    - a parent node identifier (maybe revamp as 'ecdpnid')?
166              'ecom_data_filter' => array( query_arg => 'ecdf' ),
167              
168              // Some actions ...
169              // ... required for data items.
170              'ecom_data_action_edit' => array( query_arg => 'ecdfe' ),
171              'ecom_data_action_cancel' => array( query_arg => 'ecdfc' ),
172              'ecom_data_action_delete' => array( query_arg => 'ecdfd' ),
173              'ecom_data_action_create' => array( query_arg => 'ecdfcr' ),
174              // ... required for data lists.
175              'ecom_data_form_action' => array( query_arg => 'ecdfa' ),
176              'ecom_data_form_checkbox' => array( query_arg => 'checkbox' ),
177              
178              // Special argument (should become a non-data-action).
179              // Triggers 'selectSource' at backend api (remote api) which causes a database handle switch.
180              'ecom_data_source_key' => array( query_arg => 'ecds' ),
181    
182        ),        ),
183    
184  /*  /*
185      // block model (what is used for each block)      // block model (what is used for each block)
186        // is this deprecated???
187        block => array(        block => array(
188          'ident' => array( query_arg => 'ident' ),          'ident' => array( query_arg => 'ident' ),
189          'meta' => array( query_arg => 'meta' ),          'meta' => array( query_arg => 'meta' ),
# Line 91  class WebExplorer_MVC extends Site_WebAp Line 196  class WebExplorer_MVC extends Site_WebAp
196    
197      ));      ));
198    
199        
200        // TODO: activate MVC-Views!!!
201        // - Here: Picture a ecom-component as a MVC-View.
202        // - Assign a GUID to each ecom-component!
203        // - Build WebExplorer-Introspection-Module to show stuff like this...    (->WebExplorer::Designer)
204        
205        
206      //$this->setup_views( &$this->_registry );      //$this->setup_views( &$this->_registry );
207    
208      // associate behaviour with "View"-components      // associate behaviour with "View"-components
# Line 118  class WebExplorer_MVC extends Site_WebAp Line 230  class WebExplorer_MVC extends Site_WebAp
230        // COID => '123',        // COID => '123',
231        caption => "Explorer - ExplorerDataItem",        caption => "Explorer - ExplorerDataItem",
232      ));      ));
233                      
234      // FIXME!!! enhance!?!?      // FIXME!!! enhance!?!?
235      // AIM: "dispatch a Request to a View by using rules..."      // AIM: "dispatch a Request to a View by using rules..."
236      // Todo:      // Todo:
# Line 127  class WebExplorer_MVC extends Site_WebAp Line 239  class WebExplorer_MVC extends Site_WebAp
239      //    Enhance this backend and introduce a mechanism to trigger      //    Enhance this backend and introduce a mechanism to trigger
240      //    a true callback to process a rule (or: "as a rule") on top of that.      //    a true callback to process a rule (or: "as a rule") on top of that.
241      $this->add_controller( array(      $this->add_controller( array(
242          
243        // for "module", no component registry is required, just does 'mkObject' under the hood        // for "module", no component registry is required, just does 'mkObject' under the hood
244        module => 'Application::Request::HttpController',        module => 'Application::Request::HttpController',
245          //module_options => blah
246    
247        rules => array(        rules => array(
248                    
249          // get last page state          // get last page state
250          create_function('&$_in, &$_out', '          create_function('&$_in, &$_out', '
251            $requestTracker = mkObject("Application::Request::Tracker");            $requestTracker = mkObject("Application::Request::Tracker");
252            $page_state = $requestTracker->getPointer();            $page_state = $requestTracker->getPointer();
253            $_out = $page_state[options];            $pre_out = $page_state[options];
254              //print "pre_out: " . Dumper($pre_out);
255              
256              // clean-up unwanted variables
257              $label = $_in[ecom_label];
258              switch ($_in[ecom_abstract_type]) {
259                case "list":
260                  if ($pre_out[options][ecoms][$label][ecom_data_meta]) { unset($pre_out[options][ecoms][$label][ecom_data_meta]); }
261                  if ($pre_out[options][ecoms][$label][ecom_data_meta_x]) { unset($pre_out[options][ecoms][$label][ecom_data_meta_x]); }
262                  break;
263                // 2003-04-16: required for xmltree-to-item transition
264                // if we dont do this the "dotted" filter expression would persist across views
265                case "item":
266                  if ($pre_out[options][ecoms][$label][ecom_data_filter]) { unset($pre_out[options][ecoms][$label][ecom_data_filter]); }
267                  break;
268              }
269              $_out = $pre_out;
270            '),
271    
272            // reset machine
273            create_function('&$_in, &$_out', '
274                // HACK!!!
275                // FIXME: review and implement in a more clean way?
276                //print "RESET!<br/>";
277                $_out[options][ecoms][phase_startup] = "RESET";
278          '),          '),
279    
280          // rewrite idents          // rewrite idents
281          create_function('&$_in, &$_out', '          create_function('&$_in, &$_out', '
282               // map Topic to Page if exists
283               if($_in[topic]) {
284                $_in[ap] = $_in[topic];
285              }
286            $idents = array ( ap, );            $idents = array ( ap, );
287            foreach($idents as $key) {            foreach($idents as $key) {
288              $_out[options][idents][$key] = $_in[$key];              $_out[options][idents][$key] = $_in[$key];
# Line 147  class WebExplorer_MVC extends Site_WebAp Line 290  class WebExplorer_MVC extends Site_WebAp
290          '),          '),
291                    
292          // check right $_GET[ap]          // check right $_GET[ap]
293          create_function('&$_in, &$_out', 'return ($_in[ap] != "explorer") ? print "Wrong application value $_in[ap], sure this is right here?" : null;'),          create_function('&$_in, &$_out', 'return ($_in[ap] != "explorer") ? print "Wrong application value [ap]: $_in[ap], sure this is right here?<br>" : null;'),
294    
295          // write components variables to out          // write components variables to out
296          create_function('&$_in, &$_out', '          create_function('&$_in, &$_out', '
297            $vars = array( ecom_type, ecom_abstract_type, ecom_action, ecom_data_locator_key, ecom_data_ident, ecom_data_meta );            $vars = array(
298                ecom_type, ecom_abstract_type, ecom_mode, ecom_data_locator_key,
299                ecom_data_ident, ecom_data_meta, ecom_data_filter, ecom_data_meta_x
300              );
301              //  ecom_call_method, ecom_call_args
302            if($_in[ecom_label]) {            if($_in[ecom_label]) {
303              foreach($vars as $key) {              foreach($vars as $key) {
304                if($_in[$key]) {                if($_in[$key]) {
# Line 164  class WebExplorer_MVC extends Site_WebAp Line 311  class WebExplorer_MVC extends Site_WebAp
311            return;            return;
312          '),          '),
313    
314          // create default ecoms (navigation, etc.)          // create default ecoms (navigation, chooser [as of 2003-04-05] etc.)
315          create_function('&$_in, &$_out', '          create_function('&$_in, &$_out', '
316            if(!$_out[options][ecoms] || !is_array($_out[options][ecoms])) {            if(!$_out[options][ecoms] || !is_array($_out[options][ecoms])) {
317              $_out[options][ecoms] = array(              $_out[options][ecoms] = array(
318                      nav => array(                      nav => array(
319                                ecom_type => "nav",                                ecom_type => "nav",
320                                ecom_abstract_type => "list",                                ecom_abstract_type => "list",
321                                ecom_action => "nav",                                ecom_mode => "link",
322                                  ecom_data_locator_key => "rpc",
323                                  ),
324                        chooser => array(
325                                  ecom_type => "nav",
326                                  ecom_abstract_type => "list",
327                                  ecom_mode => "link",
328                                ecom_data_locator_key => "rpc",                                ecom_data_locator_key => "rpc",
329                                ),                                ),
330                    );                    );
# Line 180  class WebExplorer_MVC extends Site_WebAp Line 333  class WebExplorer_MVC extends Site_WebAp
333            return;            return;
334          '),          '),
335    
336            // handle data form action(button)
337            create_function('&$_in, &$_out', '
338              if($_in[ap] == "Benutzerverwaltung" || $_in[topic] == "Benutzerverwaltung") {
339                if(!$_out[options][ecoms][UMnav]) {
340                  $_out[options][ecoms][UMnav] = array(
341                                  ecom_type => "nav",
342                                  ecom_abstract_type => "tree",
343                                  ecom_mode => "link",
344                                  ecom_data_locator_key => "rpc",
345                                  );
346                }
347              }
348            '),
349    
350            // handle data form action(button)
351            create_function('&$_in, &$_out', '
352              $label = $_in[ecom_label];
353              if($_in[ecom_data_form_action]) {
354                //print "from action button pressed!<br>";
355               if(is_array($_in[ecom_data_form_checkbox])) {
356                $cnt = sizeof($_in[ecom_data_form_checkbox]);
357                $tmp = array();
358                foreach($_in[ecom_data_form_checkbox] as $ident) {
359                    if($ident) { array_push($tmp, $ident); }
360                }
361                if($cnt == 1) {
362                   //print "Single selection, ident : " . $tmp[0] . "<br>";
363                    $_out[options][ecoms][$label][ecom_data_ident] = $tmp[0];
364                } elseif($cnt > 1) {
365                  // TODO: implement multi-selection actions on rows(items) here!!
366                    print "Multi-Selection!! Current Ident(s) $tmp" . "<br>";
367                    $_out[options][ecoms][$label][ecom_data_ident] = $tmp;
368                }
369               } else {
370                 print "ident: " . Dumper($_out[options][ecoms][$label][ecom_data_ident]) . "<br>";
371               }
372               //$_out[options][ecoms][$label][ecom_data_meta] = $_in[ecom_data_ident];
373               $_out[options][ecoms][$label][ecom_mode] = $_in[ecom_data_form_action];
374               $_out[options][ecoms][$label][ecom_abstract_type] = "item";
375              }
376            '),
377    
378    
379            // handle data form buttons
380            create_function('&$_in, &$_out', '
381              $label = $_in[ecom_label];
382              if($_in[ecom_data_action_edit]) { $_out[options][ecoms][$label][ecom_mode] = "edit"; }
383              if($_in[ecom_data_action_cancel]) { $_out[options][ecoms][$label][ecom_mode] = "view"; }
384    
385              // Action.Create
386              if($_in[ecom_data_action_create]) {
387                print Dumper($_out[options][ecoms][$label]);
388                $_out[options][ecoms][$label][ecom_mode] = "create";
389              }
390              
391              // Action.Delete [new of 2003-04-09]
392              if ($_in[ecom_data_action_delete]) {
393                
394                //$_out[options][ecoms][content][ecom_mode] = "view";
395    
396                // the code here vanished to the component itself!
397                // could/should we do this for "edit" and/or "view" actions as well?
398                // look at ecom/FlexibleDataItem!
399    
400              }
401            
402            '),
403    
404            // propagate datasources to ecoms
405            // datasource-change requested? enhance logic here!
406            // by now each ecom-component gets injected the very same
407            // datasource if requested - otherwise everything will fall back to defaults
408            create_function('&$_in, &$_out', '
409              if ($_in[ecom_data_source_key]) {
410                
411                print "YAI: ecom_data_source_key<br/>";
412                
413                //print Dumper($_out[options][ecoms]);
414                //print "ds: " . $_in[ecom_data_source_key] . "<br/>";
415                /*
416                foreach ($_out[options][ecoms] as $name => $ecom) {
417                  print "name: $name<br/>";
418                  //$_out[options][sources][selected] = $_in[ecom_data_source];
419                  $_out[options][ecoms][$name][ecom_data_source_key] = $_in[ecom_data_source_key];
420                }
421                */
422                $_out[options][main][ecom_data_source_key] = $_in[ecom_data_source_key];
423    
424    
425                // 2003-04-07 - enhanced
426                // now activates a special ecom-component - a "RemoteAction" - replacing
427                // the "content"-ecom instead of displaying an empty page / overriding any
428                // view reached by "normal dispatching"
429    
430                $_out[options][ecoms][phase_startup] = array(
431                  ecom_type => "call",
432                  ecom_abstract_type => "auto",
433                  ecom_mode => "link",
434                  ecom_data_locator_key => "rpc",
435                  // new attributes/properties/arguments that control further / trigger different DataFlow:
436                  // FIXME: add these to declaration at top!
437                  ecom_call_method => "selectSource",
438                  ecom_call_args => $_in[ecom_data_source_key]
439                );
440    
441              }
442            '),
443            
444    
445  /*  /*
446          // translate value of argument "action" (olist => list.view, oedit => item.edit)          // translate value of argument "action" (olist => list.view, oedit => item.edit)
447          // action dispatcher          // action dispatcher

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.15

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed