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

Contents of /nfo/php/libs/org.netfrag.glib/utils/MetaBox.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Tue May 13 16:22:22 2003 UTC (21 years, 2 months ago) by joko
Branch: MAIN
CVS Tags: HEAD
initial commit

1 <?php
2
3 /**
4 * $Id: LinkBuilder.php,v 1.2 2003/04/06 04:35:58 joko Exp $
5 *
6 * $Log: LinkBuilder.php,v $
7 *
8 */
9
10 /**
11 * MetaBox
12 *
13 * This implements a "metabox widget" using phpHtmlLib.
14 *
15 * Its purpose is to show a boxed html div-/span- area
16 * containing links acting as modifiers to the current page.
17 * The link arguments are passed to down some other layers
18 * (url, link and LinkBuilder classes) to render the query string.
19 *
20 * "Modifiers" toggle certain parameters in the url, let others
21 * pass through or set some to default values.
22 * Their implementation inside the classes mentioned above
23 * is rather a HACK. The worst possible!
24 * However, we try to keep the metabox api clean.
25 *
26 * 1. Box modes:
27 * a) bar: renders the box in bar style (suitable for placing at the top of the page)
28 * b) header: renders boxed items inside the header of (e.g.) a DataItem
29 * which extends from the InfoTable having such a thing - the "title".
30 * c) portrait: boxed items are aggregated top down inside a portrait box
31 * (e.g. place a box of this style beside your content - visit this at the DataTree ...)
32 * This itself uses a fresh InfoTable to render our payload into.
33 *
34 * 2. Link modifiers:
35 * a) ViewAs
36 * b) ResetFilter
37 * c) ParentJump
38 *
39 * @todo Use this with phpDocumentIndex?
40 *
41 * @author Andreas Motl <andreas.motl@ilo.de>
42 * @package org.netfrag.glib
43 * @name MetaBox
44 *
45 */
46 class MetaBox {
47
48 var $_box;
49
50 function MetaBox($args = array()) {
51 $this->_args = $args;
52
53 switch ($this->_args[box_mode]) {
54 case 'bar':
55 $this->build_bar();
56 break;
57 case 'header':
58 $this->build_header();
59 break;
60 case 'portrait':
61 $this->build_portrait();
62 break;
63 default:
64 $this->build_default();
65 break;
66 }
67
68 }
69
70
71 function render() {
72 //print Dumper($this);
73 return $this->_box->render();
74 }
75
76 function build_default() {
77 $this->_box = html_span();
78 //$this->_box->add('n/a');
79 }
80
81 function build_bar() {
82 // MetaBox / Chooser - resolve some links
83 $this->_box = html_div();
84 $this->_box->set_style("border: 1px black solid; padding:2px;");
85 //$this->_box->set_class("contentnovertical");
86 $this->_box->add( $this->_args['caption'], html_br() );
87 if ($this->_args['payload']['list']) {
88 //$this->_box->add( "Change abstract type to (ViewAs): " );
89 //$this->_box->add( ", ViewAs: " );
90 foreach ($this->_args['payload']['list'] as $link) {
91 if ($this->_args['payload'][meta][selected] == $link[name]) { $link[name] = '[ ' . $link[name] . ' ]'; }
92 $this->_box->add( html_a( $link[url], $link[name] ), _HTML_SPACE );
93 }
94 }
95 }
96
97
98 function build_header() {
99
100 // MetaBox / Chooser - resolve / display some links which probably have been declared in some other layer
101 $this->_box = html_span();
102
103 // some stuff we don't need here since this should be as transparent / lightweight as possible
104 // KISS!
105 //$this->_box->set_style("border: 1px black solid; padding:2px;");
106 //$this->_box->set_class("contentnovertical");
107 $this->_box->add( $this->_args['caption'] );
108
109 // just the color should be, hmmm white!
110 //$this->_box->set_style("color: white;");
111
112 // stick it to the right side of the header bar
113 //$this->_box->set_style("text-align: right; width: 100%; border: 1px solid;");
114 //$this->_box->set_style("text-align: right; width: auto; float: right;");
115 //$this->_box->set_style("text-align: right; border: 1px solid; width: 500; float: none;");
116 $this->_box->set_style("position: absolute; right:20px;");
117
118 if ($this->_args['payload']['list']) {
119
120 // optional labels - don't required here since we require transparency!
121 //$this->_box->add( "Change abstract type to (ViewAs): " );
122 //$this->_box->add( ", ViewAs: " );
123
124 foreach ($this->_args['payload']['list'] as $link) {
125 if ($this->_args['payload'][meta][selected] == $link[name]) { $link[name] = '[ ' . $link[name] . ' ]'; }
126 $link = html_a( $link[url], $link[name] );
127 $link->set_style("color: yellow;");
128 $this->_box->add( $link, _HTML_SPACE );
129 }
130 }
131
132 }
133
134
135 function build_portrait() {
136
137 // MetaBox / Chooser - resolve some links
138 $this->_box = html_span();
139
140 //$this->_box->set_style("border: 1px black solid; padding:2px;");
141 $this->_box->set_style("border: 1px solid black; padding:2px; width: 100px; float: right;");
142
143 //$this->_box->set_class("contentnovertical");
144 $this->_box->add( $this->_args['caption'] );
145 if ($this->_args['payload']['list']) {
146 //$this->_box->add( "Change abstract type to (ViewAs): " );
147 //$this->_box->add( ", ViewAs: " );
148 foreach ($this->_args['payload']['list'] as $link) {
149 if ($this->_args['payload']['meta']['selected'] == $link[name]) { $link[name] = '[ ' . $link[name] . ' ]'; }
150
151 //$this->_box->add( html_a( $link[url], $link[name] ), _HTML_SPACE );
152 $this->_box->add( html_a( $link[url], $link[name] ), html_br() );
153
154 }
155 }
156 }
157
158
159 }
160
161 ?>

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