Fix error in TabForm POD (get vs getTab)

POD for WebGUI.pm
Table of Contents has tabbed interface
viewHelp filters tabs by the user's UI level
This commit is contained in:
Colin Kuskie 2006-03-06 16:30:11 +00:00
parent f3124671c9
commit 65590997b6
5 changed files with 198 additions and 37 deletions

View file

@ -51,6 +51,10 @@
- Add tests that verify the integrity of the WebGUI Database.
- Added a karma ranking system to CS threads for conducting popularity
contests.
- The main page for the Help system is now a "Table of Contents" with a
tabbed view to make scanning for content easier.
- Help for forms now shows the fields that you should see with your UI level.
There is a link to show all fields.
6.8.8
- fix [ 1437186 ] 6.8.7 deploy DataForm package does not copy fields

View file

@ -31,6 +31,17 @@ use Apache2::Const -compile => qw(OK DECLINED NOT_FOUND DIR_MAGIC_TYPE);
use Apache2::ServerUtil ();
#-------------------------------------------------------------------
=head2 handler ( requestObject )
Primary http init/response handler for WebGUI. This method decides whether to hand off the request to contentHandler() or uploadsHandler()
=head3 requestObject
The Apache2::RequestRec object passed in by Apache's mod_perl.
=cut
sub handler {
my $r = shift;
my $s = Apache2::ServerUtil->server;
@ -51,6 +62,19 @@ sub handler {
#-------------------------------------------------------------------
=head2 contentHandler ( requestObject )
Creates the WebGUI session, handles exceptional request
headers, handles special states, prints the response headers,
and (usually) prints the output of page().
=head3 requestObject
The Apache2::RequestRec object passed in by Apache's mod_perl.
=cut
sub contentHandler {
### inherit Apache request.
my $r = shift;
@ -85,12 +109,19 @@ sub contentHandler {
}
#-------------------------------------------------------------------
=head2 fixupHandler ( requestObject )
This method is here to allow proper handling of DirectoryIndexes
when someone is using the passthruUrls feature.
=head3 requestObject
The Apache2::RequestRec object passed in by Apache's mod_perl.
=cut
sub fixupHandler {
## This method is here to allow proper handling of DirectoryIndexes
# when someone is using the passthruUrls feature.
my $r = shift;
if ($r->handler eq 'perl-script' && # Handler is Perl
@ -98,14 +129,23 @@ sub fixupHandler {
$r->is_initial_req) # and this is the initial request
{
$r->handler(Apache2::Const::DIR_MAGIC_TYPE); # Hand off to mod_dir
return Apache2::Const::OK;
}
return Apache2::Const::DECLINED; # just pass it on
}
#-------------------------------------------------------------------
=head2 page ( session )
Processes operations (if any), then tries the requested method on the asset corresponding to the requested URL. If that asset fails to be created, it tries the default page.
=head3 session
The current WebGUI::Session object.
=cut
sub page {
my $session = shift;
my $assetUrl = shift;
@ -147,6 +187,17 @@ sub page {
#-------------------------------------------------------------------
=head2 processOperations ( session )
Calls the operation dispatcher using the requested operation. Currently only handles one operation per request.
=head3 session
The current WebGUI::Session object.
=cut
sub processOperations {
my $session = shift;
my $output = "";
@ -172,6 +223,17 @@ sub processOperations {
#-------------------------------------------------------------------
=head2 setup ( session )
Handles a specialState: "setup"
=head3 session
The current WebGUI::Session object.
=cut
sub setup {
my $session = shift;
require WebGUI::Operation::WebGUI;
@ -181,6 +243,17 @@ sub setup {
#-------------------------------------------------------------------
=head2 tryAssetMethod ( session )
Tries an asset method on the requested asset. Tries the "view" method if that method fails.
=head3 session
The current WebGUI::Session object.
=cut
sub tryAssetMethod {
my $session = shift;
my $asset = shift;
@ -196,6 +269,17 @@ sub tryAssetMethod {
}
#-------------------------------------------------------------------
=head2 uploadsHandler ( requestObject )
Primary http init/response handler for WebGUI.
=head3 requestObject
The Apache2::RequestRec object passed in by handler().
=cut
sub uploadsHandler {
my $r = shift;
my $ok = Apache2::Const::OK;
@ -231,6 +315,17 @@ sub uploadsHandler {
#-------------------------------------------------------------------
=head2 upgrading ( session )
Handles a specialState: "upgrading"
=head3 session
The current WebGUI::Session object.
=cut
sub upgrading {
my $session = shift;
$session->http->getHeader;

View file

@ -17,6 +17,7 @@ use WebGUI::International;
use WebGUI::Asset::Template;
use WebGUI::Macro;
use WebGUI::Utility;
use WebGUI::TabForm;
=head1 NAME
@ -26,6 +27,10 @@ Package WebGUI::Operation::Help
Handles displaying WebGUI's internal help to the user as an operation.
=cut
#-------------------------------------------------------------------
=head2 _load ( $session, $namespace )
Safely load's the Help file for the requested namespace and logs errors
@ -33,7 +38,6 @@ during the load.
=cut
#-------------------------------------------------------------------
sub _load {
my $session = shift;
my $namespace = shift;
@ -50,6 +54,8 @@ sub _load {
}
}
#-------------------------------------------------------------------
=head2 _get ( $session, $id, $namespace )
Safely load's the Help file for the requested namespace and returns
@ -57,7 +63,6 @@ the specified id (help key).
=cut
#-------------------------------------------------------------------
sub _get {
my $session = shift;
my $id = shift;
@ -71,6 +76,8 @@ sub _get {
}
}
#-------------------------------------------------------------------
=head2 _link ( $session, $id, $namespace )
Utility routine for formatting a link for returning a help entry in the requested
@ -78,12 +85,13 @@ namespace.
=cut
#-------------------------------------------------------------------
sub _link {
my $session = shift;
return $session->url->page('op=viewHelp;hid='.$session->url->escape($_[0]).';namespace='.$_[1]);
}
#-------------------------------------------------------------------
=head2 _linkTOC ( $session, $namespace )
Utility routine for formatting a link for returning a table of contents entry
@ -91,7 +99,6 @@ for a Help namespace.
=cut
#-------------------------------------------------------------------
sub _linkTOC {
my $session = shift;
return $session->url->page('op=viewHelpChapter;namespace='.$_[0]);
@ -103,7 +110,6 @@ Utility routine for returning a list of all Help files in the lib/WebGUI/Help fo
=cut
#-------------------------------------------------------------------
sub _getHelpFilesList {
my $session = shift;
my $dir = join '/', $session->config->getWebguiRoot,"lib","WebGUI","Help";
@ -119,6 +125,7 @@ sub _getHelpFilesList {
return @files;
}
#-------------------------------------------------------------------
=head2 _getHelpName ( $session, $file )
@ -128,7 +135,6 @@ will fetch the correct i18n name for the chapter.
=cut
#-------------------------------------------------------------------
sub _getHelpName {
my $session = shift;
my $file = shift;
@ -146,6 +152,8 @@ sub _getHelpName {
return $i18n->get($helpName,$file);
}
#-------------------------------------------------------------------
=head2 _related ( $session, $related )
Utility routine for returning a list of topics related the the current help
@ -158,7 +166,6 @@ a code ref, which will be executed and should return a list.
=cut
#-------------------------------------------------------------------
sub _related {
my ($session, $related) = @_;
if (ref $related eq 'CODE') {
@ -169,6 +176,45 @@ sub _related {
}
}
=head2 _columnar ( $session, $columns, $list )
Utility routine for taking a list of data and returning it multiple columns.
=head3 $session
The session object.
=head3 $columns
The number of columns to create.
=head3 $list
A scalar ref to the array of data that will be broken into columns.
=cut
sub _columnar {
my ($session, $columns, $list) = @_;
my @entries = @{ $list };
my $fraction = round(@entries/3 + 0.50);
my $output = '<tr><td valign="top">';
@entries = sort { $a->[0] cmp $b->[0] } @entries;
my $i = 0;
foreach my $helpEntry (@entries) {
my ($helpName, $helpFile) = @{ $helpEntry };
$output .= '<p><a href="'._linkTOC($session,$helpFile).'">'.$helpName."</a></p>\n";
$i++;
if ($i % $fraction == 0) {
$output .= '</td><td valign="top">';
}
}
$output .= "</tr>";
return $output;
}
#-------------------------------------------------------------------
=head2 www_viewHelp ( $session )
Display a single help entry in a namespace. The entry and namespace are passed in as
@ -177,7 +223,6 @@ UI level, and this can be toggled on and off by another form parameter, uiOverri
=cut
#-------------------------------------------------------------------
sub www_viewHelp {
my $session = shift;
return $session->privilege->insufficient() unless ($session->user->isInGroup(7));
@ -214,13 +259,14 @@ sub www_viewHelp {
);
}
#-------------------------------------------------------------------
=head2 _viewHelpIndex ( $session )
Display the index of all help entries in all namespaces.
=cut
#-------------------------------------------------------------------
sub www_viewHelpIndex {
my $session = shift;
return $session->privilege->insufficient() unless ($session->user->isInGroup(7));
@ -255,6 +301,8 @@ sub www_viewHelpIndex {
return $ac->render($output, join ': ',$i18n->get(93), $i18n->get('help index'));
}
#-------------------------------------------------------------------
=head2 www_viewHelpTOC ( $session )
Display the table of contents for the Help system. This generates a list of
@ -262,36 +310,52 @@ the assetName,macroName,topicNames for each installed Help file.
=cut
#-------------------------------------------------------------------
sub www_viewHelpTOC {
my $session = shift;
return $session->privilege->insufficient() unless ($session->user->isInGroup(7));
my @helpIndex;
my $i18n = WebGUI::International->new($session);
my %tabs;
tie %tabs, 'Tie::IxHash';
%tabs = (
other => {
label => $i18n->get('topicName', 'WebGUI'),
uiLevel => 1,
},
asset => {
label => $i18n->get('topicName', 'Asset'),
uiLevel => 1,
},
macro => {
label => $i18n->get('topicName', 'Macros'),
uiLevel => 1,
},
);
my $i;
my @files = _getHelpFilesList($session,);
my $third = round(@files/3 + 0.50);
my @entries;
my %entries;
my $tabForm = WebGUI::TabForm->new($session, \%tabs);
foreach my $fileSet (@files) {
my $file = $fileSet->[1];
push @entries, [_getHelpName($session,$file), $file];
my $tab = lc substr $file, 0, 5;
if (exists $tabs{$tab} or $tab eq "wobje") {
push @{ $entries{$tab} } , [_getHelpName($session,$file), $file];
}
else {
push @{ $entries{'other'} }, [_getHelpName($session,$file), $file];
}
}
$i = 0;
my $output = '<table width="100%" class="content"><tr><td valign="top">';
@entries = sort { $a->[0] cmp $b->[0] } @entries;
foreach my $helpEntry (@entries) {
my ($helpName, $helpFile) = @{ $helpEntry };
$output .= '<p><a href="'._linkTOC($session,$helpFile).'">'.$helpName."</a></p>\n";
$i++;
if ($i % $third == 0) {
$output .= '</td><td valign="top">';
}
foreach my $tab ( keys %tabs ) {
my $tabPut = '<table width="100%" class="content"><tr><td valign="top">';
$tabPut .= _columnar($session, 3, $entries{$tab});
$tabPut .= '</table>';
$tabForm->getTab($tab)->raw($tabPut);
}
$output .= '</td></tr></table>';
my $i18n = WebGUI::International->new($session);
my $ac = WebGUI::AdminConsole->new($session,"help");
$ac->addSubmenuItem($session->url->page('op=viewHelpIndex'),$i18n->get(95));
return $ac->render($output, join ': ',$i18n->get(93), $i18n->get('help toc'));
$tabForm->{_submit} = $tabForm->{_cancel} = '';
return $ac->render($tabForm->print, join(': ',$i18n->get(93), $i18n->get('help toc')));
}
#-------------------------------------------------------------------
=head2 www_viewHelpChapter ( $session )
@ -300,7 +364,6 @@ the form paramter "namespace".
=cut
#-------------------------------------------------------------------
sub www_viewHelpChapter {
my $session = shift;
return $session->privilege->insufficient() unless ($session->user->isInGroup(7));

View file

@ -58,7 +58,7 @@ Package that makes creating tab-based forms simple through an object-oriented AP
The best and easiest way to use this package is to just call the methods on the tabs directly.
$tabform->get($tabname)->textarea( -name=>$name, -value=>$value, -label=>$label);
$tabform->getTab($tabname)->textarea( -name=>$name, -value=>$value, -label=>$label);
=head1 SEE ALSO

View file

@ -47,7 +47,6 @@ SKIP: {
foreach my $asset ( @assets ) {
diag("Checking $asset");
my $assetObj = WebGUI::Asset->newByPropertyHashRef($session, { className=>$asset });
my $def = $asset->definition($session);
my $tableName = $def->[0]->{tableName};
my $classIds = $session->db->buildArrayRef("select distinct(assetId) from asset where className=? order by assetId", [$asset]);