/[cvs]/nfo/php/libs/org.netfrag.glib/utils/links.php
ViewVC logotype

Diff of /nfo/php/libs/org.netfrag.glib/utils/links.php

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

revision 1.1 by joko, Sun Apr 6 04:30:10 2003 UTC revision 1.6 by jonen, Sat Apr 19 16:14:56 2003 UTC
# Line 4  Line 4 
4  ##  $Id$  ##  $Id$
5  ## -------------------------------------------------------------------------  ## -------------------------------------------------------------------------
6  ##  $Log$  ##  $Log$
7    ##  Revision 1.6  2003/04/19 16:14:56  jonen
8    ##  added comment
9    ##
10    ##  Revision 1.5  2003/04/16 16:23:31  joko
11    ##  + modified viewdatanode
12    ##  + new: function view_as
13    ##
14    ##  Revision 1.4  2003/04/11 00:58:08  joko
15    ##  + link::plain
16    ##  + url::viewdatanode
17    ##
18    ##  Revision 1.3  2003/04/08 22:38:43  joko
19    ##  NEW: 'class url' as code container for some shortcut functions
20    ##
21    ##  Revision 1.2  2003/04/08 17:56:09  joko
22    ##  bugfixes
23    ##
24  ##  Revision 1.1  2003/04/06 04:30:10  joko  ##  Revision 1.1  2003/04/06 04:30:10  joko
25  ##  initial commit  ##  initial commit
26  ##  ##
# Line 76  class link { Line 93  class link {
93      // FIXME: do this more generic! use array_merge for this purpose?      // FIXME: do this more generic! use array_merge for this purpose?
94      $opts = array_merge($_GET, $_POST);      $opts = array_merge($_GET, $_POST);
95      if (!$args[ap]) { $args[ap] = $opts[ap]; }      if (!$args[ap]) { $args[ap] = $opts[ap]; }
96      $query_string = httpQuery($args);      $query_string = url::query($args);
97      return html_a($query_string, $caption);      return html_a($query_string, $caption);
98    }    }
99      
100      function action($action_name, $args = array()) {
101        $query_string = linkargs::action($action_name, $args);
102        return html_a($query_string, "[$action_name]");
103      }
104      
105      function plain($url, $caption = '') {
106        if (!$caption) { $caption = $url; }
107        return html_a($url, $caption);
108      }
109    
110  }  }
111    
# Line 108  class linkargs { Line 135  class linkargs {
135    function page($page_name, $args = array()) {    function page($page_name, $args = array()) {
136      $args[ap] = $page_name;      $args[ap] = $page_name;
137      //unset($args[ap]);      //unset($args[ap]);
138      return httpQuery($args);      return url::query($args);
139    }    }
140    
141    function topic($topic_name, $args = array()) {    function topic($topic_name, $args = array()) {
142      $args[t] = $topic_name;      $args[t] = $topic_name;
143      //unset($args[ap]);      //unset($args[ap]);
144      return httpQuery($args);      return url::query($args);
145    }    }
146        
147  }    function action($action_name, $args = array()) {
148        $args[ga] = $action_name;
149        return url::query($args);
150      }
151    
 function httpQuery($args = array()) {  
   $query_list = array();  
   foreach ($args as $key => $val) {  
     array_push($query_list, "$key=$val");  
   }  
   $query_string = join('&', $query_list);  
   if ($query_string) { $query_string = '?' . $query_string; }  
   return $query_string;  
152  }  }
153    
154    
155  function yesno($bool) {  class url {
   return $bool ? 'yes' : 'no';  
 }  
156    
157  function qLink_old($args = array()) {    function query($args = array()) {
158    return httpQuery($args);      $query_list = array();
159  }      foreach ($args as $key => $val) {
160          array_push($query_list, "$key=$val");
161        }
162        $query_string = join('&', $query_list);
163        if ($query_string) { $query_string = '?' . $query_string; }
164        return $query_string;
165      }
166    
167      // shortcut to 'link::store'
168      function short($base = '', $link_vars = array()) {
169        
170        // if $base isn't defined, use the current url as base
171        if (!$base) { $base = $_SERVER['PHP_SELF']; }
172    
173        if (constants::get('URL_ENCODE_GUID')) {
174          // store and encode the argument payload
175          $link_guid = link::store($link_vars);
176          
177          // build complete url
178          $url = $base . "?lbid=" . $link_guid;
179        } else {
180          $url = $base . url::query($link_vars);
181        }
182        
183        
184        // there you have it..
185        return $url;
186      }
187      
188      function viewdatanode($nodename, $additional = array()) {
189        
190        // REMEMBER: This is an hard coded fallback !!
191        //  Normaly args passed in as 'additional' should explicit used!
192        $final = array();
193        $defaults = array( 'ap' => 'explorer', 'ecl' => 'content' );
194        $location = array( 'ecdlk' => 'rpc' );
195        $args = array( 'ecmod' => 'view', 'ect' => 'data',  );
196        $ident = array( 'ecat' => 'list', 'ecdid' => $nodename );
197    
198        $final = php::array_join_merge($final, $defaults);
199        $final = php::array_join_merge($final, $location);
200        $final = php::array_join_merge($final, $args);
201        $final = php::array_join_merge($final, $ident);
202        
203        $final = php::array_join_merge($final, $additional);
204        
205        return url::short('', $final);
206      }
207    
208      function view_as($type) {
209        //return url::short('', array( ecat => $type ) );
210        // HACK: (like in Data::Lift::hash::auto::TopicTree)
211        $parent_identifier = $_GET[ecdid];
212        return url::viewdatanode($type, array( ecat => $type, ecdid => $parent_identifier ));
213      }
214    
215    }
216    
217  ?>  ?>

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

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