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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations)
Sun Apr 6 04:30:10 2003 UTC (21 years, 4 months ago) by joko
Branch: MAIN
initial commit

1 joko 1.1 <?
2     /*
3     ## -------------------------------------------------------------------------
4     ## $Id: utils.php,v 1.8 2003/04/04 02:00:54 joko Exp $
5     ## -------------------------------------------------------------------------
6     ## $Log: utils.php,v $
7     ## Revision 1.8 2003/04/04 02:00:54 joko
8     ## modified rTopic
9     ## new: jsAnchor
10     ##
11     ## Revision 1.7 2003/03/28 03:09:49 joko
12     ## + function pageLink
13     ##
14     ## Revision 1.6 2003/02/28 04:30:45 joko
15     ## + new shortcuts to build links/urls directly to topics etc.
16     ##
17     ## Revision 1.5 2003/02/27 18:07:49 joko
18     ## + new functions: rPage, rLink
19     ##
20     ## Revision 1.4 2003/02/22 17:38:17 cvsmax
21     ## + added array_merge of GET and POST vars
22     ##
23     ## Revision 1.3 2003/02/22 16:41:58 joko
24     ## renamed core functions
25     ##
26     ## Revision 1.2 2003/02/20 22:42:10 joko
27     ## + functions rAnchor and rLink
28     ##
29     ## Revision 1.1 2003/02/17 01:12:17 joko
30     ## + initial commit
31     ##
32     ## -------------------------------------------------------------------------
33     */
34    
35    
36     require_once("LinkBuilder.php");
37    
38     class link {
39    
40     // shortcut to 'LinkBuilder'
41     function store($link_vars = array()) {
42     $linkbuilder = new LinkBuilder();
43     $link_guid = $linkbuilder->save($link_vars);
44     return $link_guid;
45     }
46    
47     // shortcut to 'LinkBuilder'
48     function restore($guid) {
49     $linkbuilder = new LinkBuilder();
50     return $linkbuilder->load($guid);
51     }
52    
53     // shortcut to render a html-link triggering a function
54     // in the global javascript scope of the user agent
55     function js_function($js_function, $js_args = array(), $caption) {
56     $bufarr = array();
57     foreach ($js_args as $arg) {
58     array_push($bufarr, "'$arg'");
59     }
60     $bufstr = join(', ', $bufarr);
61     return html_a("javascript:$js_function($bufstr);", $caption);
62     }
63    
64     function topic($topic_name, $args = array()) {
65     $css_class = $args[_css_class];
66     unset($args[_css_class]);
67     $query_string = linkargs::topic($topic_name, $args);
68     return html_a($query_string, $topic_name, $css_class);
69     }
70    
71     function page($caption = null, $args = array(), $identifier = null) {
72     // manipulate args, merge in non-existent, but required attributes (e.g. 'ap')
73     // FIXME: do this more generic! use array_merge for this purpose?
74     $opts = array_merge($_GET, $_POST);
75     if (!$args[ap]) { $args[ap] = $opts[ap]; }
76     $query_string = httpQuery($args);
77     return html_a($query_string, $caption);
78     }
79    
80     }
81    
82     class ref {
83    
84     function action($action, $args = array()) {
85     $args[action] = $action;
86     return rAnchor($action, $args);
87     }
88    
89     function page($page_ident, $args = array()) {
90     $args[ap] = $page_ident;
91     return rAnchor($action, $args);
92     }
93    
94     function link($caption, $page_ident) {
95     $args[ap] = $page_ident;
96     return rAnchor($caption, $args);
97     }
98    
99     }
100    
101    
102    
103     class linkargs {
104    
105     function page($page_name, $args = array()) {
106     $args[ap] = $page_name;
107     //unset($args[ap]);
108     return httpQuery($args);
109     }
110    
111     function topic($topic_name, $args = array()) {
112     $args[t] = $topic_name;
113     //unset($args[ap]);
114     return httpQuery($args);
115     }
116    
117     }
118    
119    
120     function httpQuery($args = array()) {
121     $query_list = array();
122     foreach ($args as $key => $val) {
123     array_push($query_list, "$key=$val");
124     }
125     $query_string = join('&', $query_list);
126     if ($query_string) { $query_string = '?' . $query_string; }
127     return $query_string;
128     }
129    
130    
131     function yesno($bool) {
132     return $bool ? 'yes' : 'no';
133     }
134    
135     function qLink_old($args = array()) {
136     return httpQuery($args);
137     }
138    
139    
140     ?>

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