|
|
Maxscape::Page::Table Package
Member Functions
- addListToWhereClause
- AttributeParameter
- CGI_FieldKey
- CGI_FieldKeyGetColumnKeyValue
- CGI_FieldKeyGetColumnKeyValues
- CGI_FieldKeyGetKey
- CGI_FieldKeyToSelectedWhereClause
- CGI_FieldKeyToWhereClause
- changeField
- displayColumnHeaders
- displayDescField
- displayDescRecord
- displayField
- displayRecord
- displayTable
- Error
- escapeXML
- FieldDescriptionToHTML
- FormSelectGroupRecordElement
- FormSelectGroupToWhereClause
- getCGIRecordKey
- getPageElementContent
- getRecordKey
- getTextType
- insertRecord
- insertRecords
- isAKeyColumn
- KeyColumnsToWhereClase
- lastRowAsHash
- lookupColumnDescriptions
- new
- NewlineToHTMLBreak
- nextPreviousCounter
- nextPreviousDisplay
- nextPreviousDisplayTwo
- nextPreviousQuery
- nextPreviousSubmitBar
- promptDescRecord
- promptRecord
- QueryColumnsToWhereClase
- removeBlankHeaderTrailorLines
- searchStringToWhereClause
- selectRowsWidgetToWhereClause
- setCGI_TableValuesByKey
- TableField
- TableIsEmpty
- TableKey
- TableLableHashValue
- TableLables
- TableValuesAndKeyFromCGI
- updateRecord
- Widget
Synopsis
use Maxscape::Page::Table;
Description
The package generalizes the handling of tables of the Content Database.
It eases the programming greatly by providing methods to display, add, edit,
etc. database tables via a web browser.
The class can be used in two modes depending on the TableType. In the default
mode it tries to figure out how to handle a database field by its type and the
parameters passed to the member methods. In this mode the best way to render
table fields individually are callback functions passed as parameters to the
methods.
In the decribed mode the related entry of the TABLE_COLUMN_DESCRIPTION table
defines how to render fields of the table to be displayed, edited, etc.
The introduction of a table that describes how to render the presentation of
database tables has advantages compared to rendering each field of the table to
be displayed individualy, because widgets can be reused. Instead of defining
output code for each field of all tables, the related code is defined in the
describing table. Thus the presentation of a database table field becomes an
entry in the describing table. Instead of writing code for each table field, an
entry in the describing table is necessary, only.
new
Synopsis
my $Table = new Maxscape::Page::Table ( %P );
Description
Creates a new 'Table' object.
Examples
my $Table = new Maxscape::Page::Table (
TableName => 'HYPERLINKS',
TableType => 'described',
Page => $P{Page},
NoRowsMessage => $P{NoRowsMessage},
...
);
return $Page->TemplateContent (Name => 'Table.Tag') . $ColGroup
. $Page->{Object}->displayTable (
Columns => $QueryColumns,
TableType => $TableType,
KeyColumns => ['NUMBER'],
# KeyColumns => ['SENDER', 'NUMBER'],
TableDescriptionKey => $TableDescriptionKey,
FieldCallback => $FieldCallback,
Action => 'display',
# Action => $self->{Form}->{Action},
selectRowsWidget => 1,
selectRowsWidgetHeader => $selectRowsWidgetHeader,
selectRowsWidgetTrailor => $selectRowsWidgetTrailor,
displayColumnHeaders => $displayColumnHeaders,
ColumnHeadersHeader => $ColumnHeadersHeader,
ColumnHeadersTrailor => $ColumnHeadersTrailor,
RecordHeader => $RecordHeader,
RecordHeader2 => $RecordHeader2,
RecordTrailor => $RecordTrailor,
FieldHeader => $FieldHeader,
FieldHeader2 => $FieldHeader2,
FieldHeaderSpan2 => $FieldHeaderSpan2,
FieldHeader2Span2 => $FieldHeader2Span2,
FieldLabelTrailor => $FieldLabelTrailor,
FieldTrailor => $FieldTrailor,
where => $Page->{Object}->{CountWhere},
order => $order,
# group => $group,
# count => $count,
displayRowLimit => $Page->{Object}->{displayRowLimit},
) . " |
";
TableLables
Synopsis
my $TableLables = $Table->TableLables ();
Description
Returns a reference to the Maxscape::Database::TableLables hash defined in
/maxscape/lib/perl/Maxscape/Database/SiteTableColumnDescriptions.pm.
Overrides label definitions in table TABLE_COLUMN_DESCRIPTION.
Examples
my $TableLables = $Table->TableLables ();
my $Lable = ${$TableLables}{$Table->{TableName}}{$Lang}{${$Field}{Name}};
# e.g.: ${$TableLables}{USERS}{en}{USER_ID};
TableLableHashValue
Synopsis
my $LableHashValue = $Table->TableLableHashValue ();
Description
Returns a reference to the Maxscape::Database::TableLables hash defined in
/maxscape/lib/perl/Maxscape/Database/SiteTableColumnDescriptions.pm.
Overrides label definitions in table TABLE_COLUMN_DESCRIPTION.
Examples
my $LableText = $Table->TableLableHashValue ($ColumnName);
my $Lable = ${$TableLables}{$Table->{TableName}}{$Lang}{${$Field}{Name}};
# e.g.: ${$TableLables}{USERS}{en}{USER_ID};
Error
Synopsis
my $TextType = $Table->Error ();
Description
Returns an error message.
displayTable
Synopsis
my $TextType = $Table->displayTable (
TableName => $TableName,
TableType => $TableType, # '', described
Columns => $Columns,
where => $where,
order => $order,
group => $group,
...
);
Description
The displayTable function is a quite generic solution to display database
tables in HTML.
Examples
$Text = $Table->displayTable (
Columns => $QueryColumns,
TableType => $TableType,
KeyColumns => ['SENDER', 'NUMBER'],
TableDescriptionKey => $TableDescriptionKey,
FieldCallback => $FieldCallback,
Action => 'display',
selectRowsWidget => 1,
selectRowsWidgetHeader => $selectRowsWidgetHeader,
selectRowsWidgetTrailor => $selectRowsWidgetTrailor,
displayColumnHeaders => $displayColumnHeaders,
ColumnHeadersHeader => $ColumnHeadersHeader,
ColumnHeadersTrailor => $ColumnHeadersTrailor,
RecordHeader => $RecordHeader,
RecordHeader2 => $RecordHeader2,
RecordTrailor => $RecordTrailor,
FieldLabelTrailor => $FieldLabelTrailor,
FieldHeader => $FieldHeader,
FieldHeader2 => $FieldHeader2,
FieldTrailor => $FieldTrailor,
where => $Where,
order => $order,
displayRowLimit => $Page->{Object}->{displayRowLimit},
displayRowSkip => $Page->{Object}->{displayRowSkip},
);
displayRecord
Synopsis
my $Record = $Table->displayRecord();
Description
Returns a record of a table.
displayField
Synopsis
my $Text = $Table->displayField (
{ Name => $Table->{DB_ColumnNames}[$i],
Value => $Table->{Row}[$i],
Type => $Table->{internalDB_ColumnTypes}[$i],
Size => $Table->{internalDB_Sizes}[$i],
Index => $i,
}
);
Description
Displays a table field.
displayDescRecord
Synopsis
my $Record = $Table->displayDescRecord (%P);
Description
Displayes a described record of a database table. The fields of a described
record are described by the Content Databse TABLE_COLUMN_DESCRIPTION table.
displayColumnHeaders
Synopsis
my $ColumnHeaders = $Table->displayColumnHeaders ();
Description
Returns the column headers.
TableIsEmpty
Synopsis
my $IsEmpty = $Table->TableIsEmpty ();
Tells if a table is empty.
Description
KeyColumnsToWhereClase
Synopsis
my $Key = $Table->KeyColumnsToWhereClase (%P);
Description
Converts the tables key columns to a where clause.
TableKey
Synopsis
my $TextType = $Table->TableKey ($TableNumber);
Description
Returns the table key.
CGI_FieldKey
Synopsis
my $CGI_FieldKey = $Table->CGI_FieldKey ($ColumnName, $TableKey);
Description
Returns the table key of a field.
TableValuesAndKeyFromCGI
Synopsis
my $TableValuesFromCGI = $Table->TableValuesAndKeyFromCGI ();
Description
Returns a reference to the CGI values and key from a table.
CGI_FieldKeyToWhereClause
Synopsis
my $where = $Table->CGI_FieldKeyToWhereClause ($CGI_FieldKey);
Description
Returns a where clause for a field key.
CGI_FieldKeyGetColumnKeyValue
Synopsis
my $Key = $Table->CGI_FieldKeyGetColumnKeyValue ($CGI_FieldKey, $ColumnName);
Description
Returns the value of a field key.
CGI_FieldKeyGetColumnKeyValues
Synopsis
$Table->CGI_FieldKeyGetColumnKeyValues ($CGI_FieldKey, $ColumnName);
Description
Returns the value of field keys.
getCGIRecordKey
Synopsis
my $Key = $Table->getCGIRecordKey ($ColumnName, $Key);
Description
Returns the record key.
CGI_FieldKeyGetKey
Synopsis
my $Key = $Table->CGI_FieldKeyGetKey ($ColumnName);
Description
Returns the record key.
CGI_FieldKeyToSelectedWhereClause
Synopsis
my $where = $Table->CGI_FieldKeyToSelectedWhereClause ($ColumnName, $Operator);
Description
Returns a where key to the selected key.
selectRowsWidgetToWhereClause
Synopsis
$Table->selectRowsWidgetToWhereClause ($where);
Description
Returns a where cause to a selected widget.
FormSelectGroupToWhereClause
Synopsis
$Table->FormSelectGroupToWhereClause ( %P );
Description
Returns a where clause from a selected group.
isAKeyColumn
Synopsis
my $isAKeyColumn = $Table->isAKeyColumn ($ColumnName);
Description
Returns if a column is a key column.
NewlineToHTMLBreak
Synopsis
my $Text = $Table->NewlineToHTMLBreak ($Text);
Description
Converts new line characters into HTML break tags.
displayDescField
Synopsis
$Table->displayDescField ($Field, $ColDesc);
Description
Displays a 'described' record of a table.
getTextType
Synopsis
my $TextType = $Table->getTextType (Content => $default,
ContentType => $ContentType);
Description
Returns the 'ContentType'.
Widget
Synopsis
my $Widget = $Table->Widget ($Field, $ColDesc);
Description
Returns a widget described in the 'TABLE_COLUMN_DESCRIPTION' table and
the related output function.
FieldDescriptionToHTML
Synopsis
$Table->FieldDescriptionToHTML ($CGI_Value, $Field, $ColumnDescription);
Description
Returs a the HTML of a described widget.
AttributeParameter
Synopsis
my $AttributeParameter = $self->AttributeParameter($Attribute, $Parameter);
Description
Returns the 'Type' parameter value of the taken attribute, if called with the
'Parameter' parameter. Else if no 'Parameter' parameter is passed to the
subroutine, returns a hash reference containing the values of all attribute
parameters of the form:
my1stParameter="myParameterValue" my2ndParameter="myParameterValue" a.s.o.
Examples
if ($self->AttributeParameter($Attribute, 'Type') eq 'parsed') {
...
}
my $ElementAttributeHashReference =
$self->AttributeParameter(${$Element}{ELEMENT_ATTRIBUTE});
my $TypeValue = ${$ElementAttributeHashReference}{Type};
getPageElementContent
Synopsis
my $ElementContent = getPageElementContent (Name => 'Element.Name',);
Description
Returns the content of an element.
TableField
Synopsis
Description
Function may be used in a 'RecordFormatFunction'.
changeField
Synopsis
$Table->changeField ($ColumnName, $FieldValue);
Description
Changes a field.
updateRecord
Synopsis
my $ErrorText = $self->{Cursor}->updateRecord(
ColumnName => $ColumnName,
ColumnValue => $ColumnValue,
where => "(NODE_NUMBER = $PageNumber)",
);
Description
Changes the record(s) given by the functions parameters.
promptRecord
Synopsis
$Table->promptRecord ( %P );
Description
Prompts for a record.
lookupColumnDescriptions
Synopsis
my $Error = $Table->lookupColumnDescriptions ($TableName, $TableDescriptionKey);
promptDescRecord
Synopsis
$Table->promptDescRecord ( %P );
Description
Prompts for a 'descibed' record.
insertRecord
Synopsis
my $Message = $Table->insertRecord ( );
Description
Inserts a record to the tables.
Examples
my $Message = $Table->insertRecord(FieldsToChangeByName =>
{
USER_ID => $Page->{UserData}->UserId(),
},
ColumnValues => $Page->{CGI},
);
if ($Message) {
&::LogError('Page.Table.insertRecord:, $Message, $Page->{Object}->{TableName});
$Text .= $Message;
} else {
$Page->{Object}->{TableChanged} = 1;
}
nextPreviousCounter
Synopsis
my $Text = $Table->nextPreviousCounter ( %P );
Description
Widget to move within the table.
Examples
my $Text = $Table->nextPreviousCounter (
TableName => 'T1,T2',
CountColumn => 'INTEREST_GROUPS',
displayRowLimit => $Page->{Data}{HyperlinksDisplayRowLimit},
where => $Page->{Object}->{CountWhere},
);
nextPreviousSubmitBar
Synopsis
my $nextPreviousSubmitBar = $self->nextPreviousSubmitBar (style => '');
Description
Returns a submit bar to select the wanted entries in a table.
nextPreviousQuery
Synopsis
$Table->nextPreviousQuery ( %P );
Description
Query for the 'nextPreviousSubmitBar' method.
Examples
$Table->nextPreviousQuery (
# Page => $Page,
displayRowLimit => 15,
KeyColumn => 'USER_NUMBER',
CountWhere => "not (USER_ID='" . $Page->{UserData}->UserId . "')",
);
nextPreviousDisplay
Synopsis
my (($x1, $x2) = $Table->nextPreviousDisplay ( %P );
Description
Returns a next/previous widget.
Examples
my ($x1, $x2) = $Table->nextPreviousDisplay (
#Page => $Page,
KeyColumn => 'USER_NUMBER',
);
nextPreviousDisplayTwo
Synopsis
my ($nextPreviousDisplay, $displayRowStartHidden)
= $Table->nextPreviousDisplayTwo ( %P );
Description
Another 'nextPreviousDisplay' widget.
Examples
my ($nextPreviousWidget, $displayRowStartHidden) =
$Page->{Table}->nextPreviousDisplayTwo (
#Page => $Page,
KeyColumn => 'USER_NUMBER',
);
my ($nextPreviousDisplay, $displayRowStartHidden) = $Page->{Object}->nextPreviousDisplayTwo (
KeyColumn => 'SONG_NUMBER',
#CategoryName => "/User/Messages",
#PageName => $::WebServer->{'Page.defaultName'},
QueryString => "&QueryOrderBy=$Page->{CGI}->{QueryOrderBy}",
);
escapeXML
Synopsis
my $Text = $self->escapeXML($Text);
Examples
my $Text = $self->escapeXML($Text);
Description
Escapes XML text.
FormSelectGroupRecordElement
Synopsis
$Table->FormSelectGroupRecordElement ( $P );
Description
Returns a form select group widget.
lastRowAsHash
Synopsis
my $lastFetchedRow = $Table->lastRowAsHash ();
Description
Returns the last fetched row.
getRecordKey
Synopsis
$Table->getRecordKey($Value);
Description
Function only used to edit pages in Strinx
addListToWhereClause
Synopsis
$Table->addListToWhereClause( %P );
Description
Only used in Maxscape/Database/DBQueryForm.pm.
setCGI_TableValuesByKey
Synopsis
$Table->setCGI_TableValuesByKey( $FieldKey, $ColumnName, $Value );
Description
Sets CGI values. Used in PageAdmin.pm
searchStringToWhereClause
Synopsis
my $searchWhere = $Table->searchStringToWhereClause (%P);
Description
Examples
my $searchWhere = $Page->{Object}->searchStringToWhereClause (
FieldName => 'USER_ID',
CGI_FieldKey => $CGI_FieldKey,
searchString => $Page->{CGI}->{$CGI_FieldKey},
# CGI => $Page->{CGI}, # not implemented.
);
QueryColumnsToWhereClase
Synopsis
$Table->QueryColumnsToWhereClase( %P );
Description
Only used in Maxscape/Database/DBQueryForm.pm.
insertRecords
Synopsis
$Table->insertRecords( %P );
Description
Inserts records.
removeBlankHeaderTrailorLines
Synopsis
my $Text = $Table->removeBlankHeaderTrailorLines ($Text);
Description
Removes blank header ad trailor lines.