cvsuser 02/02/05 14:18:49
Modified: P5EEx/Blue/P5EEx/Blue/Context HTML.pm
Log:
added logic to display the current widget
Revision Changes Path
1.3 +39 -6 p5ee/P5EEx/Blue/P5EEx/Blue/Context/HTML.pm
Index: HTML.pm
===================================================================
RCS file: /cvs/public/p5ee/P5EEx/Blue/P5EEx/Blue/Context/HTML.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -r1.2 -r1.3
--- HTML.pm 1 Feb 2002 20:31:58 -0000 1.2
+++ HTML.pm 5 Feb 2002 22:18:49 -0000 1.3
@@ -1,6 +1,6 @@
#############################################################################
-## $Id: HTML.pm,v 1.2 2002/02/01 20:31:58 spadkins Exp $
+## $Id: HTML.pm,v 1.3 2002/02/05 22:18:49 spadkins Exp $
#############################################################################
package P5EEx::Blue::Context::HTML;
@@ -67,10 +67,6 @@
=head2 display_current_widget()
-The display_current_widget() method searches the "default widget" for an
-attribute of "wname" and uses that as the name of the widget which should
-be displayed in the browser.
-
* Signature: $context->display_current_widget()
* Param: void
* Return: void
@@ -81,11 +77,48 @@
$context->display_current_widget();
+The display_current_widget() method searches the "global widget" for an
+attribute of "current_widget" and uses that as the name of the widget which should
+be displayed in the browser.
+
=cut
sub display_current_widget {
my $self = shift;
- $self->display_items("Hello world!"); # temporary
+
+ my ($current_widget, $w);
+ $current_widget = $self->wget("global","current_widget");
+
+ if (!$current_widget) { # no current widget is defined
+
+ # maybe it arrived in a CGI variable named "wname"
+ $current_widget = $self->{cgi}->param("wname");
+ $self->wset("global","current_widget",$current_widget) if ($current_widget);
+
+ # maybe we can find it in the {initconfig}
+ if (!$current_widget && defined $self->{initconfig}{defaultWname}) {
+ $current_widget = $self->{initconfig}{defaultWname};
+ $self->wset("global","current_widget",$current_widget) if
($current_widget);
+ }
+
+ # maybe we can infer it from the PATH_INFO
+ if (!$current_widget && defined $ENV{PATH_INFO}) {
+ $current_widget = $ENV{PATH_INFO};
+ $current_widget =~ s!^/!!; # remove leading "/"
+ # TODO: I may interpret PATH_INFO to include method(args) someday
+ $current_widget =~ s!/!.!g; # for now, convert "/" to "."
(/app/toolbar => app.toolbar)
+ $self->wset("global","current_widget",$current_widget) if
($current_widget);
+ }
+
+ # oh well. just use "default".
+ if (!$current_widget) {
+ $current_widget = "default";
+ $self->wset("global","current_widget",$current_widget);
+ }
+ }
+
+ $w = $self->widget($current_widget);
+ $self->display_items($w);
}
#############################################################################