Fixing stuff

This commit is contained in:
Wouter van Oijen 2006-05-21 14:49:40 +00:00
parent 38c78e3c62
commit 684f08649d
27 changed files with 672 additions and 414 deletions

View file

@ -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

View file

@ -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);

View file

@ -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.

View file

@ -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 = "<script type=\"text/javascript\">\n";
}
#-------------------------------------------------------------------
=head1 www_editFieldSave
=head2 www_editFieldSave ( )
Processes and stores the field properties, and will alter the table according to these properties.
@ -2028,7 +2066,8 @@ my $regexName = $self->session->form->process("regex_name") || 'untitled';
}
#-------------------------------------------------------------------
=head1 www_editFieldType
=head2 www_editFieldType ( )
Returns the form for editing field types. Only allows editing of field types that are not in use by
any SQLForm asset withing the instance. Pass the field type id through the form param 'ftid'. Pass
@ -2104,7 +2143,8 @@ sub www_editFieldType {
}
#-------------------------------------------------------------------
=head1 www_editFieldTypeSave
=head2 www_editFieldTypeSave ( )
Saves the field type properties entered in the form returned by www_editFieldType to the database. The form
param 'ftid' is used to pass the field type id. Setting the id to 'new' will create a new field type.
@ -2127,21 +2167,22 @@ sub www_editFieldTypeSave {
}
#-------------------------------------------------------------------
=head1 _getFieldValue ( field, recordValues, readOnly )
=head2 _getFieldValue ( field, recordValues, readOnly )
Returns the the value for the field represented by the field hashref for the current record, If the record
has no value for this field it will return the default value. The returned value has the correct data type
for the for element that belongs to the field.
=head2 field
=head3 field
A hashref containing the field properties of this field.
=head2 recordValues
=head3 recordValues
A hasref containg the values of this record.
=head2
=head3 readOnly
A boolean indicating the value should be outputted in read only mode.
@ -2187,28 +2228,27 @@ sub _getFieldValue {
}
#-------------------------------------------------------------------
=head1 _getFormElement ( field, recordValues, readOnly )
=head2 _getFormElement ( field, recordValues, readOnly )
Returns the for element tied to this field.
=head2 field
=head3 field
A hashref containing the field properties of this field.
=head2 recordValues
=head3 recordValues
A hasref containg the values of this record.
=head2
=head3 readOnly
A boolean indicating the value should be outputted in read only mode.
=cut
sub _getFormElement {
my ($fieldValue, $readOnly, $fieldParameters, $maxLength, $fieldType, $formElement, $cmd, $i18n);
my ($fieldValue, $fieldParameters, $maxLength, $fieldType, $formElement, $cmd, $i18n);
my $self = shift;
my $field = shift;
my $recordValues = shift;
@ -2279,7 +2319,8 @@ sub _getFormElement {
}
#-------------------------------------------------------------------
=head1 www_editRecord
=head2 www_editRecord ( )
Generates the record edit form for the record with the id given by the form param 'rid'. Setting rid to 'new' will
cause a new record to be added. If the user is not allowed to edit but can view, this method will output in view
@ -2404,7 +2445,8 @@ sub www_editRecord {
}
#-------------------------------------------------------------------
=head1 www_editRecordSave
=head2 www_editRecordSave ( )
Will process and save the record data inputted in the form generated by www_editRecord. In errors occur they will
be fed back to www_editRecord. Set the record id using the form param 'rid', and use 'new' as id to add a new
@ -2608,7 +2650,8 @@ my $cmd = '$result = 0 if ($fieldValueCompare '.$self->_resolveFieldConstrai
}
#-------------------------------------------------------------------
=head1 www_editRegex
=head2 www_editRegex ( )
Returns the form for editing regexes. Pass the id of the regex you want to edit in the form param 'regexId'. To
add a new regex pass 'new' for the regex id.
@ -2676,7 +2719,8 @@ sub www_editRegex {
}
#-------------------------------------------------------------------
=head1 www_editRegexSave
=head2 www_editRegexSave ( )
Saves the regex properties entered in the form generated by www_editRegex to the database. Pass the regex id
in the form param 'regexId'. Set the id to 'new' to add a regex.
@ -2710,7 +2754,8 @@ sub www_editRegexSave {
}
#-------------------------------------------------------------------
=head1 www_listFields
=head2 www_listFields ( )
Shows the list of fields, including edit and delete buttons.
@ -2763,7 +2808,8 @@ sub www_listFields {
}
#-------------------------------------------------------------------
=head1 www_listFieldTypes
=head2 www_listFieldTypes ( )
Shows the list of field types.
@ -2840,7 +2886,8 @@ my $currentRow = '<tr align="left" bgcolor="#bbbbbb">';
}
#-------------------------------------------------------------------
=head1 www_listRegexes
=head2 www_listRegexes ( )
Displays the list of regexes.
@ -2917,7 +2964,8 @@ my $currentRow = '<tr align="left" bgcolor="#bbbbbb">';
}
#-------------------------------------------------------------------
=head1 www_moveFieldDown
=head2 www_moveFieldDown ( )
Moves the field one position to the end in the field ordering. The field id should be passed in the form param 'fid'.
@ -2948,7 +2996,8 @@ sub www_moveFieldDown {
}
#-------------------------------------------------------------------
=head1 www_moveFieldUp
=head2 www_moveFieldUp ( )
Moves the field one position to the beginning in the field ordering. The field id should be passed in the form param 'fid'.
@ -2979,7 +3028,8 @@ sub www_moveFieldUp {
}
#-------------------------------------------------------------------
=head1 www_purgeRecord
=head2 www_purgeRecord ( )
Will purge a record from the record trash. The id of the record must be passed in form param 'rid'.
@ -3002,11 +3052,13 @@ sub www_purgeRecord {
}
#-------------------------------------------------------------------
=head1 www_purgeTrash
=head2 www_purgeTrash ( )
Purges every record that is in the record trash.
=cut
sub www_purgeTrash {
my $self = shift;
@ -3020,7 +3072,8 @@ sub www_purgeTrash {
}
#-------------------------------------------------------------------
=head1 www_viewHistory
=head2 www_viewHistory ( )
Shows the history of a record. The record id should be passed through the form param 'rid'.
@ -3082,7 +3135,8 @@ sub www_viewHistory {
}
#-------------------------------------------------------------------
=head1 www_viewFile
=head2 www_viewFile ( )
Returns the file saved in a file upolad field, and sets the mime-type to the correct value. Pass the record id
via form param 'rid' and the field id of the upload field through form param 'fid'. Optionally you can pass the
@ -3126,7 +3180,8 @@ sub www_viewFile {
}
#-------------------------------------------------------------------
=head1 www_restoreRecord
=head2 www_restoreRecord ( )
Restores a record in the record trash. Pass the record id through for param 'rid'.
@ -3154,7 +3209,8 @@ sub www_restoreRecord {
}
#-------------------------------------------------------------------
=head1 www_search
=head2 www_search ( )
Generates the normal search form.
@ -3368,7 +3424,8 @@ my $sql = $self->_constructSearchQuery(\@searchIn, \@showFields, \%fieldPropert
}
#-------------------------------------------------------------------
=head1 www_processAjaxRequest
=head2 www_processAjaxRequest ( )
Returns an XML string containing database information, depending on the form params passed. If you pass a database
name in form param 'dbName' only, this method will return an XML string containing the tables available within that
@ -3426,15 +3483,16 @@ my @zut;
}
#-------------------------------------------------------------------
=head1 _constructSearchForm ( fieldList, fieldProperties )
=head2 _constructSearchForm ( fieldList, fieldProperties )
Returns the form for super search.
=head2 fieldList
=head3 fieldList
Arrayref containing the field that should be included in the search.
=head2 fieldProperties
=head3 fieldProperties
Hashref containing the properties of the fields that are in the search.
@ -3596,19 +3654,20 @@ my $cmd = "WebGUI::Form::$searchElement".'($self->session, $parameters)';
}
#-------------------------------------------------------------------
=head1 _constructSearchQuery ( searchInFields, showFields, fieldProperties )
=head2 _constructSearchQuery ( searchInFields, showFields, fieldProperties )
Constructs an SQL query from the search query
=head2 searchInFields
=head3 searchInFields
Arrayref containing the field id's that should be included in the search.
=head2 showFields
=head3 showFields
List of field id's that should be shown in the results.
=head2 fieldProperties
=head3 fieldProperties
Hashref containing the properties of the fields that are in the search.
@ -3766,19 +3825,20 @@ my $sortAscending = $self->session->form->process("sortAscending");
}
#-------------------------------------------------------------------
=head1 _processSearchQuery ( sth, showFields, fieldProperties )
=head2 _processSearchQuery ( sth, showFields, fieldProperties )
Processes the results of a search query and returns an arrayref suitable for use as a template loop.
=head2 sth
=head3 sth
Statement handle of the executed query.
=head2 showFields
=head3 showFields
List of field id's that should be shown in the results.
=head2 fieldProperties
=head3 fieldProperties
Hashref containing the properties of the fields that are in the search.
@ -3862,7 +3922,8 @@ my $value;
}
#-------------------------------------------------------------------
=head1 www_superSearch
=head2 www_superSearch
Returns the super search.

View file

@ -19,6 +19,7 @@ use Finance::Quote;
our @ISA = qw(WebGUI::Asset::Wobject);
#-------------------------------------------------------------------
=head2 _appendStockVars ( hash, data, symbol )
Appends stock variables for the symbol passed in to the hash passed in
@ -91,7 +92,8 @@ sub _appendStockVars {
}
#-------------------------------------------------------------------
=head2 _na( string )
=head2 _na ( string )
If string passed in is empty, returns N/A
@ -110,7 +112,8 @@ sub _na {
}
#-------------------------------------------------------------------
=head2 _appendZero( intger )
=head2 _appendZero( integer )
Appends a zero to an integer if it is 0-9
@ -130,7 +133,8 @@ sub _appendZero {
}
#-------------------------------------------------------------------
=head2 _convertToEpoch (date,time)
=head2 _convertToEpoch ( date, time )
Converts the date and time returned by Finance::Quote to an epoch
@ -163,13 +167,14 @@ sub _convertToEpoch {
}
#-------------------------------------------------------------------
=head2 _getStocks ( stocks )
Private method which retrieves stock information from the Finance::Quote package
=head3 stocks
list of stock symbols to find passed in as an array reference. stock symbols should all be uppercase
List of stock symbols to find passed in as an array reference. Stock symbols should all be uppercase.
=cut
@ -187,6 +192,7 @@ sub _getStocks {
}
#-------------------------------------------------------------------
=head2 _getStockSources ( )
Private method which retrieves the list of available stock sources from Finance::Quote package
@ -211,9 +217,10 @@ sub _getStockSources {
}
#-------------------------------------------------------------------
=head2 _submenu
renders the admin console view
Renders the admin console view
=cut
@ -229,9 +236,10 @@ sub _submenu {
}
#-------------------------------------------------------------------
=head2 _trim (str)
Trims whitespace form front and end of a string
=head2 _trim ( str )
Trims whitespace form front and end of a string
=head3 str
@ -248,7 +256,8 @@ sub _trim {
}
#-------------------------------------------------------------------
=head2 definition
=head2 definition ( )
defines wobject properties for Stock Data instances
@ -292,9 +301,10 @@ sub definition {
}
#-------------------------------------------------------------------
=head2 getEditForm
returns the tabform object that will be used in generating the edit page for Stock Lists
Returns the tabform object that will be used in generating the edit page for Stock Lists
=cut
@ -362,6 +372,7 @@ sub prepareView {
#-------------------------------------------------------------------
=head2 purge ( )
removes collateral data associated with a StockData when the system
@ -375,6 +386,7 @@ sub purge {
}
#-------------------------------------------------------------------
=head2 view ( )
method called by the www_view method. Returns a processed template
@ -424,6 +436,7 @@ sub view {
}
#-------------------------------------------------------------------
=head2 www_displayStock ( )
Web facing method which allows users to view details about their stocks

View file

@ -41,7 +41,6 @@ Displays items and channels from RSS feeds.
use WebGUI::Asset::Wobject::SyndicatedWobject;
=head1 METHODS
These methods are available from this class:
@ -144,7 +143,7 @@ sub definition {
sub _strip_html {
#my ($data) = @_;
if (ref($_[0]) eq 'HASH') {
keys(%{$_[0]});
while (my ($name, $val) = each (%{$_[0]})) {
@ -164,7 +163,7 @@ sub _strip_html {
$_[0] =~ s/\&amp;(?=(#[0-9]+|#x[0-9a-fA-F]+|\w+);)/&/g;
}
}
return $_[0];
}
@ -174,7 +173,7 @@ sub _strip_html {
sub _find_record {
my ($data, $regex) = @_;
if (ref($data) eq 'HASH') {
# reset the hash before calling each()
keys(%{$data});
@ -212,11 +211,11 @@ sub _find_record {
sub _normalize_items {
#my ($items) = @_;
# max number of words to take from description to fill in an empty
# title
my $max_words = 10;
for my $item (@{$_[0]}) {
if ($item->{guid} && ($item->{guid} =~ /^http:\/\//i)) {
$item->{link} = $item->{guid};
@ -230,7 +229,7 @@ sub _normalize_items {
' ...';
}
}
# IE doesn't recognize &apos;
$item->{title} =~ s/&apos;/\'/;
$item->{description} =~ s/&apos;/\'/;
@ -241,7 +240,7 @@ sub _normalize_items {
sub _get_rss_data {
my $session = shift;
my $url = shift;
my $cache = WebGUI::Cache->new($session,'url:' . $url, 'RSS');
my $rss_serial = $cache->get;
my $rss = {};
@ -268,7 +267,7 @@ sub _get_rss_data {
}
}
my $rss_lite = {};
eval {
XML::RSSLite::parseXML($rss_lite, \$xml);
@ -279,7 +278,7 @@ sub _get_rss_data {
#but it SHOULDN'T have a major effect.
return undef;
}
# make sure that the {channel} points to the channel
# description record and that {items} points to the list
# of items. without this voodoo, different versions of
@ -295,7 +294,7 @@ sub _get_rss_data {
$session->errorHandler->warn("unable to find item info for url $url");
$rss->{items} = [];
}
_strip_html($rss);
$rss->{items} = [ $rss->{items} ] unless (ref $rss->{items} eq 'ARRAY');
@ -309,7 +308,7 @@ sub _get_rss_data {
#Default to an hour timeout
$cache->set(Storable::freeze($rss), 3600);
}
return $rss;
}
@ -321,7 +320,7 @@ sub _get_rss_data {
sub _assign_rss_dates {
my $session = shift;
my ($items) = @_;
for my $item (@{$items}) {
my $key = 'dates:' . ($item->{guid} || $item->{title} ||
$item->{description} || $item->{link});
@ -343,20 +342,20 @@ sub _assign_rss_dates {
# is the order the items are output.
sub _create_grouped_items{
my($items,$rss_feeds,$maxHeadlines,$hasTermsRegex)=@_;
_create_interleaved_items($items,$rss_feeds,$maxHeadlines,$hasTermsRegex);
@$items=sort{$a->{'site_title'} cmp $b->{'site_title'}} @$items;
#Loop through the items and output the "site_
my $siteTitleTracker;
foreach(@$items){
if($siteTitleTracker ne $_->{site_title}){
$_->{new_rss_site}=1;
my($items,$rss_feeds,$maxHeadlines,$hasTermsRegex)=@_;
_create_interleaved_items($items,$rss_feeds,$maxHeadlines,$hasTermsRegex);
@$items=sort{$a->{'site_title'} cmp $b->{'site_title'}} @$items;
#Loop through the items and output the "site_
my $siteTitleTracker;
foreach (@$items) {
if ($siteTitleTracker ne $_->{site_title}) {
$_->{new_rss_site} = 1;
}
$siteTitleTracker = $_->{site_title};
}
$siteTitleTracker=$_->{site_title};
}
}
@ -365,7 +364,7 @@ sub _create_grouped_items{
# and push in the items in "interleaved mode"
# No need to return because we're doing everything by reference.
sub _create_interleaved_items{
sub _create_interleaved_items {
my($items,$rss_feeds,$maxHeadlines,$hasTermsRegex)=@_;
my $items_remain = 1;
while((@$items < $maxHeadlines) && $items_remain){
@ -379,7 +378,7 @@ sub _create_interleaved_items{
$item->{site_link}=$rss->{channel}->{link};
if(! $hasTermsRegex || _check_hasTerms($item,$hasTermsRegex)){
push @{$items},$item;
}
}
if (@{$rss->{items}}) {
$items_remain = 1;
}
@ -395,20 +394,20 @@ sub _create_interleaved_items{
#
sub _check_hasTerms{
my($item,$hasTermsRegex)=@_;
my $to_check=$item->{title}.$item->{description};
if( $to_check =~ /$hasTermsRegex/gism){
return 1;
} else {
return 0;
}
my($item,$hasTermsRegex)=@_;
my $to_check=$item->{title}.$item->{description};
if ($to_check =~ /$hasTermsRegex/gism) {
return 1;
} else {
return 0;
}
}
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
sub _make_regex{
my $terms=shift;
my @terms=split(/,/,$terms);
return join('|',@terms);
my $terms = shift;
my @terms = split(/,/,$terms);
return join('|',@terms);
}
@ -437,7 +436,7 @@ sub _get_items {
my $self = shift;
my $urls = shift;
my $maxHeadlines = shift || $self->getValue('maxHeadlines');
my $displayMode=$self->getValue('displayMode');
my $hasTermsRegex=_make_regex($self->getValue('hasTerms'));
@ -449,7 +448,7 @@ sub _get_items {
my @rss_feeds;
if (!$items) {
$items = [];
for my $url (@{$urls}) {
my $rss_info=_get_rss_data($self->session,$url);
push(@rss_feeds, $rss_info) if($rss_info);
@ -463,12 +462,12 @@ sub _get_items {
} else {
_create_interleaved_items($items,\@rss_feeds,$maxHeadlines,$hasTermsRegex);
}
#@{$items} = sort { $b->{date} <=> $a->{date} } @{$items};
$cache->set(Storable::freeze($items), 3600);
}
#So return the item loop and the first RSS feed, because
#when we're parsing a single feed we can use that feed's title and
#description for channel.title, channel.link, and channel.description
@ -495,7 +494,7 @@ sub prepareView {
#-------------------------------------------------------------------
=head2 purgeCache ()
=head2 purgeCache ( )
See WebGUI::Asset::purgeCache() for details.
@ -507,8 +506,9 @@ sub purgeCache {
$self->SUPER::purgeCache;
}
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
=head2 view()
#-------------------------------------------------------------------
=head2 view ( )
Returns the rendered output of the wobject.
@ -572,14 +572,14 @@ sub view {
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
sub _constructRSSHeadTitleLink{
my $self = shift;
my($var,$rssTitle)=@_;
my($var,$rssTitle)=@_;
my $i18n = WebGUI::International->new($self->session,'Asset_SyndicatedContent');
my $rssFeedSuffix=$i18n->get('RSS Feed Title Suffix');
my $title = ($rssTitle) ? ($rssTitle." ".$rssFeedSuffix) : $rssFeedSuffix;
my $rssFeedSuffix=$i18n->get('RSS Feed Title Suffix');
my $title = ($rssTitle) ? ($rssTitle." ".$rssFeedSuffix) : $rssFeedSuffix;
$title =~ s/\"/&quot;/g;
$self->session->style->setLink($var->{'rss.url'},
{ rel=> 'alternate',
type=> 'application/rss+xml',
$self->session->style->setLink($var->{'rss.url'},
{ rel=> 'alternate',
type=> 'application/rss+xml',
title=> ($rssTitle) ? ($rssTitle." ".$rssFeedSuffix) : $rssFeedSuffix }
);
}
@ -610,18 +610,18 @@ sub _constructRSS{
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
sub _createRSSURLs{
my $self=shift;
my $var=shift;
foreach({ver=>'1.0',param=>'10'},{ver=>'0.9',param=>'090'},{ver=>'0.91',param=>'091'},{ver=>'2.0',param=>'20'}){
my $self=shift;
my $var=shift;
foreach({ver=>'1.0',param=>'10'},{ver=>'0.9',param=>'090'},{ver=>'0.91',param=>'091'},{ver=>'2.0',param=>'20'}){
$var->{'rss.url.'.$_->{ver}}=$self->getUrl('func=viewRSS'.$_->{param});
}
$var->{'rss.url'}=$self->getUrl('func=viewRSS20');
}
$var->{'rss.url'}=$self->getUrl('func=viewRSS20');
}
#-------------------------------------------------------------------
=head2 www_view ()
=head2 www_view ( )
See WebGUI::Asset::Wobject::www_view() for details.
@ -633,55 +633,59 @@ sub www_view {
$self->SUPER::www_view(@_);
}
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
=head2 www_viewRSS090()
#-------------------------------------------------------------------
=head2 www_viewRSS090 ( )
Emit an RSS 0.9 feed.
=cut
sub www_viewRSS090{
sub www_viewRSS090 {
my $self=shift;
return $self->view('0.9');
}
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
=head2 www_viewRSS091()
#-------------------------------------------------------------------
=head2 www_viewRSS091 ( )
Emit an RSS 0.91 feed.
=cut
sub www_viewRSS091{
my $self=shift;
return $self->view('0.91');
sub www_viewRSS091 {
my $self=shift;
return $self->view('0.91');
}
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
=head2 www_viewRSS10()
#-------------------------------------------------------------------
=head2 www_viewRSS10 ( )
Emit an RSS 1.0 feed.
=cut
sub www_viewRSS10{
my $self=shift;
return $self->view('1.0');
sub www_viewRSS10 {
my $self=shift;
return $self->view('1.0');
}
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
=head2 www_viewRSS20()
#-------------------------------------------------------------------
=head2 www_viewRSS20 ( )
Emit an RSS 2.0 feed.
=cut
sub www_viewRSS20{
my $self=shift;
return $self->view('2.0');
sub www_viewRSS20 {
my $self=shift;
return $self->view('2.0');
}

View file

@ -147,7 +147,6 @@ sub getSessionVars {
return ($session) unless (scalar(@vars) > 0);
my @list = ();
my $session = $self->session;
push(@list, $session);
foreach my $var (@vars) {
@ -713,7 +712,6 @@ sub _buildRow {
my $self = shift;
my ($session,$dt,$i18n,$eh,$form,$db,$user) = $self->getSessionVars("datetime","i18n","errorHandler","form","db","user");
my $var = {};
my $entry = $_[0] || {};
my $rowCount = $_[1];
my $daysInWeek = $_[2];
@ -746,7 +744,7 @@ sub _buildRow {
});
my $taskName = "taskId_$rowCount";
my $taskId = "taskId_".$rowCount."_formId";
$taskId = "taskId_".$rowCount."_formId";
$var->{'form.project'} = WebGUI::Form::selectBox($session,{
-name=>"projectId_$rowCount",
-options=>$projectList,

View file

@ -33,7 +33,8 @@ our @ISA = qw(WebGUI::Asset::Wobject);
#-------------------------------------------------------------------
=head2 definition
=head2 definition ( )
defines wobject properties for WeatherData instances
@ -73,7 +74,8 @@ sub definition {
}
#-------------------------------------------------------------------
=head2 _getLocationData
=head2 _getLocationData ( )
Accepts an array ref of locations, and returns
@ -108,6 +110,7 @@ sub _getLocationData {
}
#-------------------------------------------------------------------
=head2 _chooseWeatherConditionsIcon ( currentSkyConditionsEnglish )
Accepts a string that represents the current sky conditions. Taken
@ -146,7 +149,8 @@ if (isIn($currCond,'Haze')) {return 'mist';}
}
#-------------------------------------------------------------------
=head2 _na( string )
=head2 _na ( string )
If string passed in is empty, returns N/A
@ -165,6 +169,7 @@ sub _na {
}
#-------------------------------------------------------------------
=head2 _trim (str)
Trims whitespace form front and end of a string
@ -201,6 +206,7 @@ sub prepareView {
#-------------------------------------------------------------------
=head2 view ( )
method called by the www_view method. Returns a processed template

View file

@ -19,7 +19,8 @@ use WebGUI::Utility;
use base 'WebGUI::Asset::Wobject';
#-------------------------------------------------------------------
=head2 definition
=head2 definition ( )
defines wobject properties for New Wobject instances. You absolutely need
this method in your new Wobjects. If you choose to "autoGenerateForms", the
@ -70,7 +71,8 @@ sub definition {
#-------------------------------------------------------------------
=head2 duplicate
=head2 duplicate ( )
duplicates a New Wobject. This method is unnecessary, but if you have
auxiliary, ancillary, or "collateral" data or files related to your
@ -85,7 +87,8 @@ sub duplicate {
}
#-------------------------------------------------------------------
=head2 getEditForm
=head2 getEditForm ( )
returns the tabform object that will be used in generating the edit page for New Wobjects.
This method is optional if you set autoGenerateForms=1 in the definition.
@ -123,6 +126,7 @@ sub prepareView {
#-------------------------------------------------------------------
=head2 purge ( )
removes collateral data associated with a NewWobject when the system
@ -140,6 +144,7 @@ sub purge {
}
#-------------------------------------------------------------------
=head2 view ( )
method called by the www_view method. Returns a processed template
@ -163,6 +168,7 @@ sub view {
}
#-------------------------------------------------------------------
=head2 www_edit ( )
Web facing method which is the default edit page. This method is entirely