diff --git a/lib/WebGUI/Asset/File/ZipArchive.pm b/lib/WebGUI/Asset/File/ZipArchive.pm index a2a67f3af..59ebc589f 100644 --- a/lib/WebGUI/Asset/File/ZipArchive.pm +++ b/lib/WebGUI/Asset/File/ZipArchive.pm @@ -39,7 +39,6 @@ containing related items. An asset setting will set the launch point of the arc use WebGUI::Asset::ZipArchive; - =head1 METHODS These methods are available from this class: @@ -48,36 +47,37 @@ These methods are available from this class: #------------------------------------------------------------------- sub unzip { - my $self = shift; - my $storage = $_[0]; - my $filename = $_[1]; + my $self = shift; + my $storage = shift; + my $filename = shift; - my $filepath = $storage->getPath(); - chdir $filepath; + my $filepath = $storage->getPath(); + chdir $filepath; my $i18n = WebGUI::International->new($self->session,"Asset_ZipArchive"); - if($filename =~ m/\.zip/i){ - my $zip = Archive::Zip->new(); - unless ($zip->read($filename) == $zip->AZ_OK){ - $self->session->errorHandler->warn($i18n->get("zip_error")); - return 0; - } - $zip->extractTree(); - } elsif($filename =~ m/\.tar/i){ - Archive::Tar->extract_archive($filepath.'/'.$filename,1); - if (Archive::Tar->error){ - $self->session->errorHandler->warn(Archive::Tar->error); - return 0; - } - } else{ - $self->session->errorHandler->warn($i18n->get("bad_archive")); - } - - return 1; + if ($filename =~ m/\.zip/i) { + my $zip = Archive::Zip->new(); + unless ($zip->read($filename) == $zip->AZ_OK){ + $self->session->errorHandler->warn($i18n->get("zip_error")); + return 0; + } + $zip->extractTree(); + } elsif ($filename =~ m/\.tar/i) { + Archive::Tar->extract_archive($filepath.'/'.$filename,1); + if (Archive::Tar->error) { + $self->session->errorHandler->warn(Archive::Tar->error); + return 0; + } + } else { + $self->session->errorHandler->warn($i18n->get("bad_archive")); + } + + return 1; } #------------------------------------------------------------------- -=head2 addRevision + +=head2 addRevision ( ) This method exists for demonstration purposes only. The superclass handles revisions to ZipArchive Assets. @@ -91,6 +91,7 @@ sub addRevision { } #------------------------------------------------------------------- + =head2 definition ( definition ) Defines the properties of this asset. @@ -102,32 +103,33 @@ A hash reference passed in from a subclass definition. =cut sub definition { - my $class = shift; - my $session = shift; - my $definition = shift; + my $class = shift; + my $session = shift; + my $definition = shift; my $i18n = WebGUI::International->new($session,"Asset_ZipArchive"); - push(@{$definition}, { - assetName=>$i18n->get('assetName'), - tableName=>'ZipArchiveAsset', - icon=>'ziparchive.gif', - className=>'WebGUI::Asset::File::ZipArchive', - properties=>{ - showPage=>{ - fieldType=>'text', - defaultValue=>'index.html' - }, - templateId=>{ - fieldType=>'template', - defaultValue=>'' - }, - } - }); - return $class->SUPER::definition($session,$definition); + push(@{$definition}, { + assetName=>$i18n->get('assetName'), + tableName=>'ZipArchiveAsset', + icon=>'ziparchive.gif', + className=>'WebGUI::Asset::File::ZipArchive', + properties=>{ + showPage=>{ + fieldType=>'text', + defaultValue=>'index.html' + }, + templateId=>{ + fieldType=>'template', + defaultValue=>'' + }, + } + }); + return $class->SUPER::definition($session,$definition); } #------------------------------------------------------------------- -=head2 duplicate + +=head2 duplicate ( ) This method exists for demonstration purposes only. The superclass handles duplicating ZipArchive Assets. This method will be called @@ -143,31 +145,31 @@ sub duplicate { #------------------------------------------------------------------- -=head2 getEditForm () + +=head2 getEditForm ( ) Returns the TabForm object that will be used in generating the edit page for this asset. =cut sub getEditForm { - my $self = shift; - my $tabform = $self->SUPER::getEditForm(); + my $self = shift; + my $tabform = $self->SUPER::getEditForm(); my $i18n = WebGUI::International->new($self->session,"Asset_ZipArchive"); - $tabform->getTab("display")->template( - -value=>$self->getValue("templateId"), - -label=>$i18n->get('template label'), - -namespace=>"ZipArchiveAsset" - ); - $tabform->getTab("properties")->text ( - -name=>"showPage", - -label=>$i18n->get('show page'), - -value=>$self->getValue("showPage"), - -hoverHelp=>$i18n->get('show page description'), - ); - return $tabform; + $tabform->getTab("display")->template( + -value=>$self->getValue("templateId"), + -label=>$i18n->get('template label'), + -namespace=>"ZipArchiveAsset" + ); + $tabform->getTab("properties")->text ( + -name=>"showPage", + -label=>$i18n->get('show page'), + -value=>$self->getValue("showPage"), + -hoverHelp=>$i18n->get('show page description'), + ); + return $tabform; } - #------------------------------------------------------------------- =head2 prepareView ( ) @@ -186,6 +188,7 @@ sub prepareView { #------------------------------------------------------------------- + =head2 processPropertiesFromFormPost ( ) Used to process properties from the form posted. In this asset, we use @@ -203,30 +206,31 @@ sub processPropertiesFromFormPost { #return unless $file; my $i18n = WebGUI::International->new($self->session, 'Asset_ZipArchive'); - unless($self->session->form->process("showPage")) { - $storage->delete; - $self->session->db->write("update FileAsset set filename=NULL where assetId=".$self->session->db->quote($self->getId)); - $self->session->scratch->set("za_error",$i18n->get("za_show_error")); - return; + unless ($self->session->form->process("showPage")) { + $storage->delete; + $self->session->db->write("update FileAsset set filename=NULL where assetId=".$self->session->db->quote($self->getId)); + $self->session->scratch->set("za_error",$i18n->get("za_show_error")); + return; } - unless($file =~ m/\.tar/i || $file =~ m/\.zip/i) { - $storage->delete; - $self->session->db->write("update FileAsset set filename=NULL where assetId=".$self->session->db->quote($self->getId)); - $self->session->scratch->set("za_error",$i18n->get("za_error")); - return; + unless ($file =~ m/\.tar/i || $file =~ m/\.zip/i) { + $storage->delete; + $self->session->db->write("update FileAsset set filename=NULL where assetId=".$self->session->db->quote($self->getId)); + $self->session->scratch->set("za_error",$i18n->get("za_error")); + return; } unless ($self->unzip($storage,$self->get("filename"))) { - $self->session->errorHandler->warn($i18n->get("unzip_error")); + $self->session->errorHandler->warn($i18n->get("unzip_error")); } } #------------------------------------------------------------------- + =head2 view ( ) -method called by the container www_view method. In this asset, this is +Method called by the container www_view method. In this asset, this is used to show the file to administrators. =cut @@ -261,6 +265,7 @@ sub view { #------------------------------------------------------------------- + =head2 www_edit ( ) Web facing method which is the default edit page @@ -277,6 +282,7 @@ sub www_edit { } #------------------------------------------------------------------- + =head2 www_view ( ) Web facing method which is the default view page. This method does a diff --git a/lib/WebGUI/Asset/Wobject/InOutBoard.pm b/lib/WebGUI/Asset/Wobject/InOutBoard.pm index 1fa6d6d24..4404012c1 100644 --- a/lib/WebGUI/Asset/Wobject/InOutBoard.pm +++ b/lib/WebGUI/Asset/Wobject/InOutBoard.pm @@ -8,7 +8,6 @@ use WebGUI::International; use WebGUI::Paginator; use WebGUI::SQL; use WebGUI::Asset::Wobject; -use Data::Dumper; our @ISA = qw(WebGUI::Asset::Wobject); diff --git a/lib/WebGUI/Asset/Wobject/MultiSearch.pm b/lib/WebGUI/Asset/Wobject/MultiSearch.pm index e31e1581e..def80a1a3 100644 --- a/lib/WebGUI/Asset/Wobject/MultiSearch.pm +++ b/lib/WebGUI/Asset/Wobject/MultiSearch.pm @@ -32,6 +32,7 @@ our @ISA = qw(WebGUI::Asset::Wobject); #------------------------------------------------------------------- + =head2 definition defines wobject properties for MultiSearch instances @@ -98,7 +99,7 @@ sub prepareView { #------------------------------------------------------------------- -=head2 purgeCache () +=head2 purgeCache ( ) See WebGUI::Asset::purgeCache() for details. @@ -111,6 +112,7 @@ sub purgeCache { } #------------------------------------------------------------------- + =head2 view ( ) method called by the www_view method. Returns a processed template @@ -139,10 +141,9 @@ sub view { return $out; } - #------------------------------------------------------------------- -=head2 www_view () +=head2 www_view ( ) See WebGUI::Asset::Wobject::www_view() for details. diff --git a/lib/WebGUI/Asset/Wobject/SQLForm.pm b/lib/WebGUI/Asset/Wobject/SQLForm.pm index 002f255ee..713d67052 100644 --- a/lib/WebGUI/Asset/Wobject/SQLForm.pm +++ b/lib/WebGUI/Asset/Wobject/SQLForm.pm @@ -27,6 +27,12 @@ use Tie::IxHash; our @ISA = qw(WebGUI::Asset::Wobject); +=head1 NAME + +Package WebGUI::Asset::Wobject::SQLForm + +=cut + #------------------------------------------------------------------- # This hash contains the allowed database field types. Keys indicate the MySQL name of the field type and # the values are the the way they are showed in the form. @@ -476,9 +482,15 @@ my $typeFunctions = { list => 'switchListField', }; +=head1 METHODS + +These methods are available from this class: + +=cut #------------------------------------------------------------------- -=head1 _canAlterTable + +=head2 _canAlterTable ( ) Returns a boolean indicating whether the user is allowed to change (alter) the table structure. Ie. manage field etc. @@ -491,7 +503,8 @@ sub _canAlterTable { } #------------------------------------------------------------------- -=head1 _canEditRecord + +=head2 _canEditRecord ( ) Returns a boolean indicating whether the user is allowed to edit, delete and restore records. @@ -504,7 +517,8 @@ sub _canEditRecord { } #------------------------------------------------------------------- -=head1 _canPurge + +=head2 _canPurge ( ) Returns a boolean indictating whether the user is allowed to purge deleted records. @@ -517,11 +531,12 @@ sub _canPurge { } #------------------------------------------------------------------- -=head1 _constructColumnType ( fieldProperties ) + +=head2 _constructColumnType ( fieldProperties ) Will construct a MySQL column definition string from the field properties passed as argument. -=head2 fieldProperties +=head3 fieldProperties A hashref containing the properties of the field for which this column definition is made. Properties taken into account are: @@ -562,15 +577,16 @@ sub _constructColumnType { } #------------------------------------------------------------------- -=head1 _createFieldType ( dbFieldType, formFieldType ) + +=head2 _createFieldType ( dbFieldType, formFieldType ) Inserts a new field type into the SQLForm_fieldTypes table. -=head2 dbFieldType +=head3 dbFieldType The column type connected to this field type. -=head2 formFieldType +=head3 formFieldType The form element to be used for this field type. @@ -590,7 +606,8 @@ sub _createFieldType { } #------------------------------------------------------------------- -=head1 _getDbLink + +=head2 _getDbLink ( ) Returns a WebGUI::DatabaseLink object for the database the SQLForm table is in. @@ -603,11 +620,12 @@ sub _getDbLink { } #------------------------------------------------------------------- -=head1 _getFieldProperties ( fieldId ) + +=head2 _getFieldProperties ( fieldId ) Returns a hashref containing the properties of the field indicated by fieldId. -=head2 fieldId +=head3 fieldId The id of the field of which the properties should be returned. @@ -665,7 +683,8 @@ my $sth = $dbLink->db->unconditionalRead($definition{sqlQuery}." order by ".$de } #------------------------------------------------------------------- -=head1 _getDatabaseInfo + +=head2 _getDatabaseInfo ( ) Returns a hashref containing all tables and columns including column properties in the database in which the SQLForm resides. @@ -702,7 +721,8 @@ sub _getDatabaseInfo { } #------------------------------------------------------------------- -=head1 _getManagementLinks + +=head2 _getManagementLinks ( ) Returns a string containg all of the management function the user is allowed to use. @@ -724,16 +744,17 @@ sub _getManagementLinks { } #------------------------------------------------------------------- -=head1 _matchField ( string, regexId ) + +=head2 _matchField ( string, regexId ) Excutes the regex identified by regexId on the string passed as first argument and return a boolean indicating whether it is a match or not. Will return true if no regex id or a non-existing regex id is passed. -=head2 string +=head3 string The string to be matched. -=head2 regexId +=head3 regexId The id of the regex to used. @@ -758,11 +779,12 @@ sub _matchField { } #------------------------------------------------------------------- -=head1 _resolveFieldConstraintType ( type ) { + +=head2 _resolveFieldConstraintType ( type ) Translates the numerical value used in field constraint types to a perl operator. -=head2 type +=head3 type The numerical id for the operator. If omitted this method will return a hasref containing all numerical <-> operator mappings. @@ -782,7 +804,8 @@ sub _resolveFieldConstraintType { } #------------------------------------------------------------------- -=head1 definition + +=head2 definition ( ) The asset definition of the SQLForm. @@ -848,7 +871,8 @@ sub definition { } #------------------------------------------------------------------- -=head1 uiLevel + +=head2 uiLevel ( ) The uiLevel of the SQLForm asset. It is a power tool so the uiLevel is set to 9. @@ -859,7 +883,8 @@ sub uiLevel { } #------------------------------------------------------------------- -=head1 getAdminConsoleWithSubmenu + +=head2 getAdminConsoleWithSubmenu ( ) Return the adminconsole but adds three submenu items for manage fields/field types/regexes. @@ -879,7 +904,8 @@ sub getAdminConsoleWithSubmenu { } #------------------------------------------------------------------- -=head1 getEditForm + +=head2 getEditForm ( ) Creates the edit form of the SQLForm asset. @@ -996,7 +1022,8 @@ sub getEditForm { } #------------------------------------------------------------------- -=head1 getIndexerParams + +=head2 getIndexerParams ( ) Should index the data in the table of this SQLForm. Not functional in 6.8.x due to a crippled search framework. @@ -1044,7 +1071,8 @@ sub getIndexerParams { } #------------------------------------------------------------------- -=head1 getName + +=head2 getName ( ) Return the internationalized name of the SQLForm. @@ -1057,7 +1085,8 @@ sub getName { } #------------------------------------------------------------------- -=head1 processPropertiesFromFormPost + +=head2 processPropertiesFromFormPost ( ) Processes the data in the edit form of the SQLForm asset. In WebGUI 6.8.x there's no way to feed back any errors on asset addition. Therefore if something is wrong this method will use die to stop the processing. This will heave the @@ -1171,7 +1200,7 @@ sub processPropertiesFromFormPost { # __recordId and __revision are always unique and hence the pk. my %dropKeys; my $hasPrimaryKey = 0; - my $sth = $dbLink->db->read("show keys from $tableName"); + $sth = $dbLink->db->read("show keys from $tableName"); while (my %row = $sth->hash) { if ($row{Key_name} eq 'PRIMARY') { $hasPrimaryKey = 1; @@ -1257,7 +1286,8 @@ my $hasPrimaryKey = 0; } #------------------------------------------------------------------- -=head1 purge + +=head2 purge ( ) This method purges the Asset completely from the WebGUI instance. @@ -1273,7 +1303,8 @@ sub purge { } #------------------------------------------------------------------- -=head1 view + +=head2 view ( ) The view function of the Asset. @@ -1291,7 +1322,8 @@ sub view { } #------------------------------------------------------------------- -=head1 www_deleteFieldType + +=head2 www_deleteFieldType ( ) This will delete the field type with the id that is passed in a form param called 'ftid'. @@ -1318,7 +1350,8 @@ sub www_deleteFieldType { } #------------------------------------------------------------------- -=head1 www_deleteRecord + +=head2 www_deleteRecord ( ) Will put the record with the id given by the form param 'rid', in the trash of the SQLForm. @@ -1342,7 +1375,8 @@ sub www_deleteRecord { } #------------------------------------------------------------------- -=head1 www_deleteRegex + +=head2 www_deleteRegex ( ) Deletes the regex with the id given in the form param 'regexId'. @@ -1363,7 +1397,8 @@ sub www_deleteRegex { } #------------------------------------------------------------------- -=head1 www_disableField + +=head2 www_disableField ( ) Will mark the field indicated by the id given by the form param 'fid' as deleted. This means that the field is not included in searches and edits. No data is actually purged though. @@ -1385,7 +1420,8 @@ sub www_disableField { } #------------------------------------------------------------------- -=head1 www_enableField + +=head2 www_enableField ( ) Will mark the 'deleted' field identified by the id given in the form param 'fid' as normal again. @@ -1401,7 +1437,8 @@ sub www_enableField { } #------------------------------------------------------------------- -=head1 www_editField + +=head2 www_editField ( ) Returns the 'edit field properties' form of the field attached to the id given in form param 'fid'. If fid is set to 'new' it will add a new field. The form generated relies heavily on three javascript files included in the @@ -1471,7 +1508,7 @@ my %fieldTypes = $self->session->db->buildHash('select fieldTypeId, concat(formF ); } -my $tabForm = WebGUI::TabForm->new($self->session, undef, undef, $self->getUrl('func=listFields')); + $tabForm = WebGUI::TabForm->new($self->session, undef, undef, $self->getUrl('func=listFields')); $tabForm->hidden({ name => 'func', value => 'editFieldSave' @@ -1756,7 +1793,8 @@ my $js = "