From 5f71b0e5f2886337ba37160b0c226c919c93a618 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Wed, 10 May 2006 23:28:50 +0000 Subject: [PATCH] Add method to return help if set in AdminConsole Alter storage object so that errors array is created by default. This prevent getErrorCount from dying when fetching the error count and no errors have occured. Added a method to to return the errors arrayref. --- lib/WebGUI/AdminConsole.pm | 1 + lib/WebGUI/Storage.pm | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/WebGUI/AdminConsole.pm b/lib/WebGUI/AdminConsole.pm index 847509cbe..2677f91e8 100644 --- a/lib/WebGUI/AdminConsole.pm +++ b/lib/WebGUI/AdminConsole.pm @@ -34,6 +34,7 @@ The admin console is a menuing system to manage webgui's administrative function addSubmenuItem getAdminConsoleParams getAdminFunction + getHelp new render setHelp diff --git a/lib/WebGUI/Storage.pm b/lib/WebGUI/Storage.pm index ddf6d7355..fb7946064 100644 --- a/lib/WebGUI/Storage.pm +++ b/lib/WebGUI/Storage.pm @@ -47,6 +47,7 @@ This package provides a mechanism for storing and retrieving files that are not $filename = $store->addFileFromHashref($filename,$hashref); $filename = $store->addFileFromScalar($filename,$content); + $arrayref = $store->getErrors; $integer = $store->getErrorCount; $hashref = $store->getFileContentsAsHashref($filename); $string = $store->getFileContentsAsScalar($filename); @@ -420,7 +421,7 @@ sub get { my $id = shift; return undef unless $id; $id =~ m/^(.{2})(.{2})/; - my $self = {_session=>$session, _id => $id, _part1 => $1, _part2 => $2}; + my $self = {_session=>$session, _id => $id, _part1 => $1, _part2 => $2, _errors => []}; bless $self, ref($class)||$class; $self->_makePath unless (-e $self->getPath); # create the folder in case it got deleted somehow return $self; @@ -441,6 +442,20 @@ sub getErrorCount { } +#------------------------------------------------------------------- + +=head2 getErrors ( ) + +Returns an arrayref with all errors for this object + +=cut + +sub getErrors { + my $self = shift; + return $self->{_errors}; +} + + #------------------------------------------------------------------- =head2 getFileContentsAsScalar ( filename )