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

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

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

revision 1.1 by jonen, Sun Apr 6 01:28:04 2003 UTC revision 1.9 by jonen, Tue Aug 31 14:22:03 2004 UTC
# Line 4  Line 4 
4   * $Id$   * $Id$
5   *   *
6   * $Log$   * $Log$
7     * Revision 1.9  2004/08/31 14:22:03  jonen
8     * added removing of 'template' hash-value, needed to recognize empty hash-refs
9     *
10     * Revision 1.8  2003/12/14 01:52:26  jonen
11     * implemented 'SELECT' mode for selecting existing object-refereneces as child-nodes
12     *
13     * Revision 1.7  2003/07/02 12:32:27  jonen
14     * fixed bugs
15     *
16     * Revision 1.6  2003/05/10 18:17:19  jonen
17     * + added 'create/add new' links
18     *
19     * Revision 1.5  2003/04/18 13:38:40  jonen
20     * + added use of url::short function at 'decode_item_expr'
21     *
22     * Revision 1.4  2003/04/16 16:22:01  joko
23     * + introduced url::short
24     *
25     * Revision 1.3  2003/04/09 07:57:15  joko
26     * revamped 'function decode_item_expr'
27     * introduced shortcut 'link::store'
28     *
29     * Revision 1.2  2003/04/09 00:32:42  jonen
30     * some tests according to form rendering at the decode functions
31     *
32   * Revision 1.1  2003/04/06 01:28:04  jonen   * Revision 1.1  2003/04/06 01:28:04  jonen
33   * + initial commit   * + initial commit
34   * + moved decode functions here   * + moved decode functions here
# Line 30  Line 55 
55    
56    
57      // TODO: refactor to Data::Lift - subcomponent: handling will get way more easy!      // TODO: refactor to Data::Lift - subcomponent: handling will get way more easy!
58      function decode_item_array($item, $hidden_elements, $options) {      function decode_item_array(&$item, $hidden_elements, $options) {
59        //$options = $this->_options['decode_args'];        //$options = $this->_options['decode_args'];
60        //print "item: " . Dumper($item);        //print "item: " . Dumper($item);
61        //print "options: " . Dumper($options);        //print "options: " . Dumper($options);
62        if( is_array($item) ) {        if( is_array($item) ) {
63            //print "is_array($item)<br>";
64            //$cur_row_index = $this->_datasource->get_cur_data_index();            //$cur_row_index = $this->_datasource->get_cur_data_index();
65            //$parent_guid = $this->_datasource->_data[$cur_row_index]['guid'];            //$parent_guid = $this->_datasource->_data[$cur_row_index]['guid'];
66            // build list for selection form            // build list for selection form
67         if($options['form']) {         if($options['form']) {
68            foreach($item as $key => $value) {            foreach($item as $key => $value) {
69                  $tmp = split($options['seperator'], $value);                  $link_meta = php::untwingle_reference($value, $options);
70                  $ident = $tmp['1'];                  $link_vars = array(
71                  $meta = $tmp['2'];                                      'ecdid' => $link_meta[ident],
72                  $list[$key] = $ident;                                      'ecdm' => $link_meta[type]
73                                        );
74    
75                   foreach($hidden_elements as $label => $value) {
76                     $link_vars[$label] = $value;
77                   }
78    
79                    // V1 - create new LinkBuilder instance and get link GUID by saving vars  
80                    $link_guid = link::store($link_vars);
81    
82                    // V2 - more flexible - adjustable link shrinking via some constant defined elsewhere
83                    //$link_guid = url::short('', $link_vars);
84    
85                    $list[$key] = $link_guid;
86                  }                  }
87                  if(is_array($list) ) {                  if(is_array($list) ) {
88                $container = container(                $container = container(
89                    form_open( $item[0], $_SERVER["PHP_SELF"], "POST" ),                    //form_open( $item[0], $_SERVER['PHP_SELF'], "POST" ),
90                    form_hidden("ecdm", $meta),                    form_select("lbid", $list),
                   form_select("ecdid", $list),  
91                    form_submit("submit","view" )                    form_submit("submit","view" )
92                    );                    );
93                 foreach($hidden_elements as $label => $value) {                //$container->add(form_close() );
                  $container->add(form_hidden($label, $value));  
                }  
               $container->add(form_close() );  
94                $item = $container;                $item = $container;
95                }                }
96          } else {          } else {
97            //print "<b>2</b><br/>";            //print "<b>2</b><br/>";
98            $container = container();            $container = container();
99            foreach($item as $key => $value) {            
100                  $tmp = split($options['seperator'], $value);            // add default 'add new' link
101                  $ident = $tmp['1'];                  $link_vars_create = array(
102                  $meta = $tmp['2'];                                      'ecdid' => $options[label],
103                                                            'ecdm' => $options[parent_guid],
104                       $link_vars = array(                                      'ecdmx' => $options[parent_class],
105                                               'ecdid' => $ident,                                      'ecmod' => "create",
106                                               'ecdm' => $meta,                                      'ecat' => 'item'
107                                               );                                      );
108                         foreach($hidden_elements as $label => $value) {
109                           if(!$link_vars_create[$label]) {
110                           $link_vars_create[$label] = $value;
111                         }
112                         }
113                    $url_short = url::short($_SERVER["PHP_SELF"], $link_vars_create);
114                    $container->add(_HTML_SPACE, html_a( $url_short, $key . " add new"), html_br());              
115              
116              if($item[tmp]) { unset($item[tmp]); }
117              
118              if(count($item) != 0) {
119                foreach($item as $key => $value) {
120                    $link_meta = php::untwingle_reference($value, $options);
121                    $link_vars = array(
122                                        'ecdid' => $link_meta[ident],
123                                        'ecdm' => $link_meta[type],
124                                        'ecat' => 'item'
125                                        );
126                                            
127                       foreach($hidden_elements as $label => $value) {                       foreach($hidden_elements as $label => $value) {
128                         $link_vars[$label] = $value;                         if(!$link_vars[$label]) {
129                           $link_vars[$label] = $value;
130                         }
131                         //$tmp_array[] = $label . "=" . $value;                         //$tmp_array[] = $label . "=" . $value;
132                       }                       }
133                                            
134                       //$str_hidden = join("&", $tmp_array);                       //$str_hidden = join("&", $tmp_array);
135                  //$container->add("->", html_a($_SERVER["PHP_SELF"] . "?ecdid=" . $ident . "&ecdm=" . $meta . "&" . $str_hidden, $key . " view"), html_br());                                //$container->add("->", html_a($_SERVER["PHP_SELF"] . "?ecdid=" . $ident . "&ecdm=" . $meta . "&" . $str_hidden, $key . " view"), html_br());              
136    
137                  // create new LinkBuilder instance and get link GUID by saving vars                    // V1 - create new LinkBuilder instance and get link GUID by saving vars  
138                  $linkbuilder = new LinkBuilder();                  //$link_guid = link::store($link_vars);
139                  $link_guid = $linkbuilder->save($link_vars);                  //$container->add("->", html_a($_SERVER["PHP_SELF"] . "?lbid=" . $link_guid, $key . " view"), html_br());              
140    
141                    // V2 - more flexible - adjustable link shrinking via some constant defined elsewhere
142                    $url_short = url::short($_SERVER["PHP_SELF"], $link_vars);
143                    $container->add( _HTML_SPACE, html_a( $url_short, $key . " - " . " view"), html_br());              
144                                    
145                  $container->add("->", html_a($_SERVER["PHP_SELF"] . "?lbid=" . $link_guid, $key . " view"), html_br());                            }
146            }            }
147            $item = $container;            $item = $container;
148          }          }
149              return $item;              //return $item;
150                return 1;
151        }        }
152      }      }
153    
154      // decodes serialized string representations of object-references      // decodes serialized string representations of object-references
155      // TODO: refactor to Data::Lift - subcomponent: handling will get way more easy!      // TODO: refactor to Data::Lift - subcomponent: handling will get way more easy!
156      function decode_item_expr($item, $hidden_elements, $options) {      function decode_item_expr(&$item, $hidden_elements, $options) {
157          
158          //return;
159          
160          // debug
161        //$options = $this->_options['decode_args'];        //$options = $this->_options['decode_args'];
162        //print "item: $item<br/>";        //print "item(expr): " . Dumper($item);
163        if(substr($item, 0, 2) == "o_") {        //print "options(expr): " . Dumper($options);
           $tmp = split($options['seperator'], $item);  
           $ident = $tmp['1'];  
           $meta = $tmp['2'];  
   
           $link_vars = array(  
                                    'ecdid' => $ident,  
                                    'ecdm' => $meta,  
                                    );  
           foreach($hidden_elements as $label => $value) {  
              $link_vars[$label] = $value;  
              //$tmp_array[] = $label . "=" . $value;  
           }  
             
           //$str_hidden = join("&", $tmp_array);  
           //$item = html_a($_SERVER["PHP_SELF"] . "?ecdid=" . $ident . "&ecdm=" . $meta . "&" . $str_hidden, "view");  
164    
165            $linkbuilder = new LinkBuilder();        if($item == "_REF") {
166            $link_guid = $linkbuilder->save($link_vars);          $link_vars_create = array(
167            $item = html_a($_SERVER["PHP_SELF"] . "?lbid=" . $link_guid, "view");            'ecdid' => $options[label],
168              'ecdm' => $options[parent_guid],
169            return $item;            'ecdmx' => $options[parent_class],
170              'ecmod' => "create",
171              'ecat' => 'item'
172            );
173            foreach($hidden_elements as $label => $value) {
174              if(!$link_vars_create[$label]) {
175               $link_vars_create[$label] = $value;
176              }
177                 }
178            $url_short = url::short($_SERVER["PHP_SELF"], $link_vars_create);
179            $item = html_a( $url_short,  " create");
180          } elseif($item == "_REF_SELECT") {
181            $link_vars_create = array(
182              'ecdid' => $options[label],
183              'ecdm' => $options[parent_guid],
184              'ecdmx' => $options[parent_class],
185              'ecmod' => "select",
186              'ecat' => 'list'
187            );
188            foreach($hidden_elements as $label => $value) {
189              if(!$link_vars_create[$label]) {
190               $link_vars_create[$label] = $value;
191              }
192                 }
193            $url_short = url::short($_SERVER["PHP_SELF"], $link_vars_create);
194            $item = html_a( $url_short,  " select");
195          } else {
196            // resolve 'o_{guid}_{classname}' - encoded string
197            $link_meta = php::untwingle_reference($item);
198    
199            if (!is_array($link_meta)) {
200              //return $item;
201              //print "NO<br/>";
202              return;
203            }
204    
205            $link_vars = array(
206              'ecdid' => $link_meta[ident],
207              'ecdm' => $link_meta[type],
208              'ecat' => 'item'
209            );
210    
211            foreach($hidden_elements as $label => $value) {
212              if(!$link_vars[$label]) {
213                $link_vars[$label] = $value;
214              }
215            }
216          
217            // V1
218            //$str_hidden = join("&", $tmp_array);
219            //$item = html_a($_SERVER["PHP_SELF"] . "?ecdid=" . $ident . "&ecdm=" . $meta . "&" . $str_hidden, "view");
220    
221            // V2
222            //$link_guid = link::store($link_vars);
223            //$item = html_a($_SERVER["PHP_SELF"] . "?lbid=" . $link_guid, "view");
224    
225             // V3 - more flexible - adjustable link shrinking via some constant defined elsewhere
226            $url_short = url::short($_SERVER["PHP_SELF"], $link_vars);
227            $item = html_a( $url_short,  " view");
228        }        }
229    
230          return 1;
231      }      }
232    
233    

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.9

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