primary_column()
- select the primary display column(s)
title()
- returns a title for a particular recordrecord_label()
- returns a label for a particular recordreport()
- display record(s)
from the database as HTMLreport_row()
- display a single row in verbose formatreport_db()
- display top-level database viewreport_relational()
- displays records and their relationsreport_links()
- show DB ops links in a reportlink()
- generate a single db ops linkhelplink()
- display help tops for DB fieldsThe Report class inherits from the DB and Auth classes, and is in turn inherited by the Form class. This help document describes only the methods that are unique to the Report class. Consult the docs for inherited classes to read about inherited methods. Code that requires write access to the database will typically work with the Form class, but read-only access can use a Report object instead.
Usage: my $db = new ExSite::Report;
By default, ExSite connects to its default database, which contains all the web content data. You can connect to an alternate database using a call like this:
my $db = new ExSite::Report(type=>"sql",name=>"mydb",map=>"mapname",user=>"username",pass=>"password");
primary_column()
- select the primary display column(s)
Usage: $db->primary_column($table)
From a reporting point of view, the primary display column is the column whose data best represents the record from a human point of view. This column will be used to make record titles, and hotlinks to the record.
This is not the same as the primary key, which is the column that best represents the record from the computers point of view. For example, in a ``person'' record, the computer's primary key will probably be a numeric record ID, whereas the human-readable primary display column will probably be the person's name. However, if no primary display column is defined, the primary key will be used by default.
More than one primary display column can be defined in the DBmap, in which case an array of column names will be returned, eg. (``first_name'',``last_name'').
title()
- returns a title for a particular recordUsage: $db->title($table,$record,$rdata)
Given a table name ($table
), a record ID ($record
), and a hash ref
pointing to the record data ($rdata
), this routine will compose an
appropriate title for the record, using the table's primary display
column(s). The record title is typically:
TABLE_NAME ``PRIMARY_DISPLAY_COLUMN''
For example, Member ``John Doe'', or Website ``Acme Software, Inc.''.
record_label()
- returns a label for a particular recordUsage: $db->record_label($table,$record,$rdata)
Same as title()
, above, but returns only the quoted part of the title.
show_data()
- display individual database column values as HTMLThe show_data()
methods format database column values as HTML
according to their datatype. Web-enabled datatypes (emails, URLs) are
converted to links, machine-readable datatypes (timestamps, keys) are
converted to human-readable form, and other datatypes are preprocessed
for safe display in a browser.
Usage:
$db->show_data($table,$column,$data,$id,$datatype);
$id
is only needed for file datatypes, and $datatype
is
only needed if overriding the datatype in the DBmap.)
$db->show_data_noauth($table,$column,$data,$id,$datatype);
$id
is only needed
for file datatypes, and $datatype
is only needed if overriding the
datatype in the DBmap.)
$db->show_data_nomap($datatype,$data);
Parameters:
report()
- display record(s)
from the database as HTMLreport()
displays one or more records from the database in a formatted
table, automatically selecting which columns/values to display, formatting
each value, hyperlinking active values appropriately, and providing
options to edit, copy, delete, or view more detailed information.
It returns the report as a string of formatted HTML.
Usage: $db->report($options);
$options
is a hash reference containing any of the following parameters
that are relevant to the report:
reference to a list of tables to report on
Any record can be linked to a variety of database operations (DB ops)
that the viewer can perform on the data. The operations that will be
linked to are determined by the settings of the following DB ops flags.
If the flag is true, the link to the operation will be given. If the flag
is ``1'' the link will go to the default URL for handling DB ops (defined
in $config{db_ops}
), otherwise the flag is presumed to be a partial
URL to link to for that operation. The following parameters will be
appended to the URL:
tab=TABLENAME&id=RECORD_ID
The DB ops that the system can perform are:
edit=>1, copy=>1, delete=>1
.
Some reports may include too many records for convenient display on a
single web page. In this case, we break the report into pages. By
default we show 20 records per page, but this value can be configured
in exsite.conf
. An index of the report pages is also shown at the
bottom of the report.
A ``query'' (probably a misnomer) is a QUERY_STRING parameter that lets us keep track of where we are in a multi-page report, since we may have to re-generate the report several times as we page through it, and we need some context information to do that. The query also keeps track of which columns we are sorting on, so that we don't lose our position in the report if we resort somewhere in the middle.
All of this is handled automatically by ExSite if you use the
report()
method, in which case you should never have to interact with
the query methods.
The query parameter is just an encoded hash containing the following values:
The query parameters are processed with the following calls:
$db->encode_query($query_hashref);
$db->decode_query($encoded_query_string);
$db->do_query($query_hashref);
$db->sizeof_query();
do_query()
(not just the slice that was returned).
report_row()
- display a single row in verbose formatThis displays all viewable columns of a selected record. The results are formatted in a two-column table, with labels (user-friendly column names) on the left, and values on the right. The report is returned as a string of HTML.
Usage: $db->report_row($table,$row,%opt);
report()
, if desired. For example
(edit=>1)
.
report_db()
- display top-level database viewThis lists all viewable tables in the database, with options to view the contents of the table, search the table, or add a new record to the table.
Usage: $db->report_db($options);
$options
is a hash containing the following parameters:
display record counts for each table, if true.
report_relational()
- displays records and their relationsThis method generates contextual views of the database. A viewer may be looking at a specific record, a table, or nothing.
In the case of nothing, report_db()
is called.
In the case of a table, report()
is called.
In the case of a specific record, we call report_row()
on that
record, and then recursively generate summary reports for every child
record of this record. Each of these child records can in turn be
visited to generate new relational reports from that context. Parent
records can be visited by following the links in the the record's
data. This is the usual method for navigating/browsing the database.
b$db->report_relational($options);
HMTL for the combined report is returned in a string.
$options
is a hash containing the following parameters, all of which
are optional:
subtable(s)
to manage. By default, all known subtables are shown.
This parameter can be used to restrict which subtables are shown.
report()
methods.
report_links()
- show DB ops links in a reportThis is an internal method used to generate the DB ops links in the
above reports. Links will use graphic buttons, if those are found
where they are expected, but will default to text links if not.
report_links()
can be invoked for a table or record to generate
all of the appropriate links for that entity.
Usage: $db->report_links($table,$id,%options)
$table
$id
%options
edit=>1, copy=>1, delete=>1
.
If the flag is set to 1, the option will be linked to the default URL defined in $config{db_ops}. Otherwise, you can set the flag to your own URL to perform that operation. The following parameters will be appended to your URL:
tab=TABLENAME&id=RECORD_ID
link()
- generate a single db ops linkUsage: $db->link($op,$arg,$script)
$op
is the db operation (eg. ``view'', ``edit'', ``search'', etc.).
$arg
is an explicit query string to include, or a hash ref to
a set of parameters to convert to a query string.
$script
is a CGI program name to use in place of the default
db_ops CGI program.
link()
returns links in one of two formats, depending on the value
of $config{report}{linkmode}
. If the linkmode is ``exsite'', the
current URL is edited to include the new parameters, on the assumption
that an appropriate plug-in will act on those parameters. Otherwise
if the linkmode is ``cgi'', the link URL will be taken from $config{db_ops}
.
helplink()
- display help tops for DB fieldsThis method generates help links for DB fields in forms.
Help data is found in dbmap/help/$table/$column
.
Usage: $db->helplink($table,$column,$anchor,$css)
$table
and $column
refer to the DB column that help is
needed for. $anchor
is the anchor text for the help link.
$css
is a boolean flag that makes us use CSS help popups
(you must be using the ExSite stylesheet or equivalent); otherwise
we use JavaScript popups. It will generate a popup window if help
is available. There is no output if the help files are not found.
Bulk imports/exports are typically done to/from some spreadsheet format. Exports can be done to tab-delimted text or Excel formats. Imports are done from tab-delimited text files.
export()
Usage: $db->export($options)
$options
is a hash ref containing:
By default, all records in a table are exported, unless one of data, match, owner, or group is given.
import()
Usage: $db->import($options);
$options
is a hash ref containing:
insert
or update
. Update can be used if the imported file is
from a previous export, and includes appropriate primary keys
indicating which records are being updated. Insert should be used
for new data.