Highlighting
|

Pedigree Showing Highlighting Selector
|
Highlighting is a feature of Pedserve Pro and Advanced Editions; it is not available with Pedserve Standard Edition.
It is a way for selected records or fields to be visually marked - higlighted - in various ways.
The user may choose one of multiple highlighting methods by selecting from the highlighting pull-down menu thats shown above most search results and pedigree etc. pages.
Pedserve includes some inbuilt highlighting methods. But you can also add your own custom methods, using hooks.
|
Contents
Inbuilt Highlighting Methods
Custom Highlighting
Record-level and Field-level Highlighting
Highlighting Visual Effects
Coding a Custom Highlighting Method
- Record Level Highlighting - Filled Tiles
- Record Level Highlighting - Text Tiles
- Record Level Highlighting - Other Decorations
- Record Level Highlighting - Background Colouring
- Record Level Highlighting - Multi-Record Highlights
- Record Level Highlighting - Text Emphasis
- Record Level Highlighting - Pre/Post HTML
- Field Level Highlighting - Filled Tiles
- Field Level Highlighting - Text Tiles
- Field Level Highlighting - Other Decorations
- Field Level Highlighting - Background Colouring
- Field Level Highlighting - Text Emphasis
- Field Level Highlighting - Pre/Post HTML
|
|
Pedserve provides inbuilt highlighting methods for animal, family & mating records:
|

Ancestors Listing With Blood% Highlighted
|
'Heat coded' background shading according to the %blood contribution to the subject animal in a pedigree or ancestors report. This is where the highlight is applied as a background shade of red, starting from a very pale shade of pink going right through to intense red. You can change the colour spectrum easily e.g. to use blue shading.
This is available both for pedigrees and ancestors reports.
|

Pedigree With Blood% Highlighted
|

Pedigree With Inbreeding% Highlighting
|
'Heat coded' background shading according to the inbreeding% or relationship coefficient of the animal.
|

Pedigree With Common Ancestors Highlighted
|
Background shading to show the common ancestors within a pedigree.
A common ancestor is one that occurs on both sides of a pedigree, and therefore contributes to the inbreeding coefficient.
|

Pedigree With Repeat Ancestors Highlighted
|
Background shading to show the repeated ancestors within a pedigree.
|
|
Custom highlighting provides you with the tools you need to add your own highlighting options specific to your needs.
There are 2 types of highlighting: record and field highlighting. With record highlighting, the whole of the displayed record is shown highlighted - either the whole row in a search results screen (sample), or the whole cell for an ancestor in a pedigree (sample), etc. With field highlighting, only a single field within a record is highlighted - which means a single cell in a typical search results screen (sample), or a single field value within a pedigree ancestors cell (sample).
Record-level highlighting can be assigned in two different ways: according to properties of the individual record, or according to how a record relates to a set of records, such as the set of ancestors in a pedigree. The 2nd way is used internally to apply highlights such as 'repeat ancestors' or 'common ancestors'.
With both types of highlighting, record and field, you can choose between several different kinds visual effects for the highlight:
|

Record Highlighting - Filled Tile Highlight - Pedigree

Record Highlighting - Filled Tile Highlight - Search Results

Field Highlighting - Filled Tile Highlight - Pedigree

Field Highlighting - Filled Tile Highlight - Search Results
|
Filled Tiles - here you specify a coloured tile that is used to decorate the record or field. The tile can be hyperlinked to any URL you choose. With field-level highlighting, the tile is displayed next to the field. With record-level highlighting, in the search results pages the tile is displayed in a column of its own next to the hit no., or, in pedigree pages etc., it is displayed at the bottom of the record 'cell'.
Note the legend that appears beneath the report, giving the colour coding of the filled tiles.
|

Record Highlighting - Text Tile Highlight - Pedigree

Record Highlighting - Text Tile Highlight - Search Results

Field Highlighting - Text Tile Highlight - Pedigree

Field Highlighting - Text Tile Highlight - Search Results
|
Text Tiles - like a filled tile above, but you can supply the HTML that goes in the tile. As above the tile can be hyperlinked to any URL you choose.
|

Record Highlighting - Other Decorations - Pedigree

Record Highlighting - Other Decorations - Search Results

Field Highlighting - Other Decorations - Pedigree

Field Highlighting - Other Decorations - Search Results
|
Other Decorations - like a filled tile above, but you can supply the exact HTML of the decoration.
|

Record Highlighting - Background Highlight - Pedigree

Record Highlighting - Background Highlight - Search Results

Field Highlighting - Background Highlight - Pedigree

Field Highlighting - Background Highlight - Search Results
|
Background colouring - here you specify a background colour and/or image to highlight the record or field.
|

Record Highlighting - Text Emphasis - Pedigree

Record Highlighting - Text Emphasis - Search Results

Field Highlighting - Text Emphasis - Pedigree

Field Highlighting - Text Emphasis - Search Results
|
Text Emphasis - here you specify a text effect to be applied, such as italics or bold.
|

Record Highlighting - Pre/Post Custom HTML - Pedigree

Record Highlighting - Pre/Post Custom HTML - Search Results

Field Highlighting - Pre/Post Custom HTML - Pedigree

Field Highlighting - Pre/Post Custom HTML - Search Results
|
Pre/Post HTML - here you specify pieces of HTML that are to be inserted before, and appended after, the record/field. The HTML can be whatever you like - so you can use this as a means to apply a wide range of other custom highlights of your choice.
|
|
There are 2 parts to adding a custom highlighting method. First you must add an item to the highlighting pull-down menu. And second, you must reimplement 1 or more hooks to provide the actual highlighting logic.
All the hooks for highlighting are found in the file pedserve-hook-highlighting.pl which you will need to edit.
Adding the item to the highlighting pull-down menu is just a case of adding a call to pdsSetHighlightingDef within your pedserve-hook-setup.pl file, e.g.:
.
.
&pdsSetHighlightingDef('A_myhighlighting',
'label=Highlight DOB;myhighlighting=yes;');
.
.
The above line of code is the same as that used to add the pull-down menu item for the custom highlighting method in many of the samples shown below on this page. The label element gives the user-visible name thats added to the pull-down menu. The myhighlighting element is used by the code samples to detect when the custom code should be used. Note that the name of the highlighting definition, 'A_myhighlighting' begins with the table suffix for animal tables ('A_myhighlighting'); This is how Pedserve knows that the declared highlighting method applies to animal records, only.
For a field-level hook, you then need to reimplement hookHighlighting_GetForField and possibly hookHighlighting_GetExtraFlds.
Or, for a record-level hook, you need to reimplement hookHighlighting_GetForRecord and possibly hookHighlighting_GetExtraFlds and/or hookHighlighting_PrepareForRecordset.
You can see examples of the use of all these hooks if you examine the code for the samples further down this page.
|
|
|

Record Highlighting - Filled Tile Highlight - Pedigree

Record Highlighting - Filled Tile Highlight - Search Results
|
In this form of highlighting, you specify a coloured tile that is used to decorate the record. You need to reimplement the hookHighlighting_GetForRecord hook.
The example below shows the addition of a filled tile highlight based on the date of birth field ('A_DOB'). It shows a different colour being used for odd and even birth years; hardly a real world example but it shows the basics of getting the field data and using it to generate a highlight.
Note also the legend that appears underneath the page content - telling the user what the colours mean - and how the same highlighting code affects search results and pedigree pages in different ways. With a pedigree page, or any other place where a record is displayed as a plate, the highlight tiles are added at the end of the record. But in search results pages, the highlight tiles are placed in a separate column to the left of the hit no. column.
Show/Hide Sample Code
# Hook function to apply highlighting for a record - storing
# the required highlighting decorations in a supplied map.
#
# Arg 1 - table suffix
# Arg 2 - reference to map holding decoded highlight definition
# Arg 3 - context
# Arg 4 - reference to map into which highlight effects are to be stored
# Arg 5 - reference to map of field values
# Arg 6 - primary key
# Arg 7 - field name prefix
# Arg 8 - reference to map into which highlighting state can be
# stored for the current panel
# OPTIONAL
# Arg 9 - reference to map for future additional arguments; possibly undefined
sub hookHighlighting_GetForRecord {
my ($strTableSuffix, $rmHighlightingDef, $strContext, $rmEffects,
$rmFieldValues, $nPrimaryKey, $strFldPrefix, $rmState, $rmArgsEx) = @_;
# You probably dont want to interfere with the correct working of
# pedserve's internally defined highlighting methods.
# So what you should do is make your highlighting definition
# identifiable - by including terms that you can test
# for here. Then you can defer to the default implementation when
# necessary.
my $fUseStdImpl = 1;
# Example that checks for the term 'myhighlighting=yes' in
# the highlighting definition, and if present handles it here.
# To use this, you would have to define a highlighting during
# the script startup with a call to &pdsSetHighlightingDef() e.g.
# &pdsSetHighlightingDef('A_myhighlighting',
# 'label=Highlight DOB;myhighlighting=yes;');
# Note also the check against $strTableSuffix to ensure this is
# only used with animal records, and the check that this is
# not a pedserve-private definition:
if (!defined($$rmHighlightingDef{'pdsprivate'}) &&
$strTableSuffix eq 'A' &&
defined($$rmHighlightingDef{'myhighlighting'}) &&
$$rmHighlightingDef{'myhighlighting'} eq 'yes') {
# Dont defer to standard implementation below:
$fUseStdImpl = 0;
# This demonstrates record-level highlighting by adding
# a 'tile' to the rendered output for a record.
# A tile is a small coloured rectangle placed somewhere next
# to the rendered record. When rendering in results context,
# record highlight tiles are placed to the left of the hit #
# When rendering in plate context, record highlight tiles are
# placed underneath the record;
# The tile can contain supplied text, or can be blank.
# You can control the colour of the tile etc by setting an#
# inline CSS style. You can also make the tile link to a
# supplied URL.
# Extract the date of birth field value from the
# field results map:
my $date = $$rmFieldValues{$nPrimaryKey.':'.$strFldPrefix.'A_DOB'};
if (defined($date) && $date ne '') {
# This animal has its DOB set.
# Extract the year part:
my $strYear = substr($date, 0, 4);
# # Add a tile where the content is blank, the colour varies
# depending on whether the year is odd or even, and the
# link is to tenset:
$$rmEffects{'tile_dob_content'} = '';
$$rmEffects{'tile_dob_link'} = 'http://www.tenset.co.uk';
if (($strYear % 2) == 1 ) {
$$rmEffects{'tile_dob_inlinestyle_css'} =
'background-color: #00e0e0;';
# Set up an entry for the highlighting legend:
$$rmEffects{'tile_dob_legend'} =
$::g_q->escapeHTML("Born in an odd year");
} else {
$$rmEffects{'tile_dob_inlinestyle_css'} =
'background-color: #e000e0';
# Set up an entry for the highlighting legend:
$$rmEffects{'tile_dob_legend'} =
$::g_q->escapeHTML("Born in an even year");
}
}
}
# If the above code has not handled this highlighting definition itself,
# defer to the standard implementation:
if ($fUseStdImpl) {
&pdsHookStdImpl_Highlighting_GetForRecord(
$strTableSuffix, $rmHighlightingDef, $strContext, $rmEffects,
$rmFieldValues, $nPrimaryKey, $strFldPrefix, $rmState, $rmArgsEx);
}
}
This custom highlighting method uses the date of birth field ('A_DOB'). When Pedserve fetches data from the database, it does not automatically fetch all the fields - it only fetches those it needs. For this reason, when your custom highlighting method is selected, you need to take steps to ensure that Pedserve will pull any fields you need. You do this by reimplementing the hookHighlighting_GetExtraFlds hook:
Show/Hide Sample Code
# Hook function to return extra fields that are required by a given
# highlighting method.
#
# Arg 1 - table suffix
# Arg 2 - reference to map holding decoded highlight definition
# Arg 3 - context
# Arg 4 - field name prefix
# OPTIONAL
# Arg 4 - reference to map for future additional arguments; possibly undefined
sub hookHighlighting_GetExtraFlds {
my ($strTableSuffix, $rmHighlightingDef,
$strContext, $strFldPrefix, $rmArgsEx) = @_;
# You probably dont want to interfere with the correct working
# of pedserve's internally defined highlighting methods.
# So what you should do is make your highlighting definition
# identifiable - by including terms that you can test
# for here. Then you can defer to the default implementation
# when necessary.
my $fUseStdImpl = 1;
my $strReturn = '';
# Trivial example that checks for the term 'myhighlighting=yes'
# in the highlighting definition, and if present returns a specific
# field name. To use this, you would have to define a highlighting
# method during the script startup with a call to
# &pdsSetHighlightingDef() e.g.
# &pdsSetHighlightingDef('A_myhighlighting',
# 'label=Highlight DOB;myhighlighting=yes;');
# Note also the check against $strTableSuffix to ensure this is only
# used with animal records, and
# the check that this is not a pedserve-private definition:
if (!defined($$rmHighlightingDef{'pdsprivate'}) &&
$strTableSuffix eq 'A' &&
defined($$rmHighlightingDef{'myhighlighting'}) &&
$$rmHighlightingDef{'myhighlighting'} eq 'yes') {
# Dont defer to standard implementation below:
$fUseStdImpl = 0;
# Set the fields to return:
# (this example will use the date of birth field to apply specific
# highlights for given dates etc)
$strReturn = $strFldPrefix.'A_DOB';
}
# If the above code has not handled this highlighting definition itself,
# defer to the standard implementation:
if ($fUseStdImpl) {
$strReturn = &pdsHookStdImpl_Highlighting_GetExtraFlds($strTableSuffix,
$rmHighlightingDef, $strContext, $strFldPrefix, $rmArgsEx);
}
return $strReturn;
}
|
|
|

Record Highlighting - Text Tile Highlight - Pedigree

Record Highlighting - Text Tile Highlight - Search Results
|
This is a variation of the filled tile highlighting.
In this form of highlighting, you specify a coloured tile that is used to decorate the record, but you also specify HTML content that is to be displayed within the tile. Its entirely up to you what you use here, but typically it will be an image, or a word, etc. You need to reimplement the hookHighlighting_GetForRecord hook.
The example below shows the addition of a text tile highlight based on the date of birth field ('A_DOB'). It uses different colours & labels for odd and even birth years; again, hardly a real world example but it shows the basics of getting the field data and using it to generate a highlight.
Note also the legend that appears underneath the page content - telling the user what the colours mean - and how the same highlighting code affects search results and pedigree pages in different ways. With a pedigree page, or any other place where a record is displayed as a plate, the highlight tiles are added at the end of the record. But in search results pages, the highlight tiles are placed in a separate column to the left of the hit no. column.
Show/Hide Sample Code
# Hook function to apply highlighting for a record - storing
# the required highlighting decorations in a supplied map.
#
# Arg 1 - table suffix
# Arg 2 - reference to map holding decoded highlight definition
# Arg 3 - context
# Arg 4 - reference to map into which highlight effects are to be stored
# Arg 5 - reference to map of field values
# Arg 6 - primary key
# Arg 7 - field name prefix
# Arg 8 - reference to map into which highlighting state can be
# stored for the current panel
# OPTIONAL
# Arg 9 - reference to map for future additional arguments; possibly undefined
sub hookHighlighting_GetForRecord {
my ($strTableSuffix, $rmHighlightingDef, $strContext, $rmEffects,
$rmFieldValues, $nPrimaryKey, $strFldPrefix, $rmState, $rmArgsEx) = @_;
# You probably dont want to interfere with the correct working of
# pedserve's internally defined highlighting methods.
# So what you should do is make your highlighting definition
# identifiable - by including terms that you can test
# for here. Then you can defer to the default implementation when
# necessary.
my $fUseStdImpl = 1;
# Example that checks for the term 'myhighlighting=yes' in
# the highlighting definition, and if present handles it here.
# To use this, you would have to define a highlighting during
# the script startup with a call to &pdsSetHighlightingDef() e.g.
# &pdsSetHighlightingDef('A_myhighlighting',
# 'label=Highlight DOB;myhighlighting=yes;');
# Note also the check against $strTableSuffix to ensure this is
# only used with animal records, and the check that this is
# not a pedserve-private definition:
if (!defined($$rmHighlightingDef{'pdsprivate'}) &&
$strTableSuffix eq 'A' &&
defined($$rmHighlightingDef{'myhighlighting'}) &&
$$rmHighlightingDef{'myhighlighting'} eq 'yes') {
# Dont defer to standard implementation below:
$fUseStdImpl = 0;
# EG2. This demonstrates record-level highlighting by adding
# a 'tile' to the rendered output for a record.
# A tile is a small coloured rectangle placed somewhere next
# to the rendered record. When rendering in results context,
# record highlight tiles are placed to the left of the hit #
# When rendering in plate context, record highlight tiles are
# placed underneath the record;
# The tile can contain supplied text, or can be blank.
# You can control the colour of the tile etc by setting an#
# inline CSS style. You can also make the tile link to a
# supplied URL.
# Extract the date of birth field value from the
# field results map:
my $date = $$rmFieldValues{$nPrimaryKey.':'.$strFldPrefix.'A_DOB'};
if (defined($date) && $date ne '') {
# This animal has its DOB set.
# Extract the year part:
my $strYear = substr($date, 0, 4);
# Add a tile where the content is blank, the colour varies
# depending on whether the year is odd or even, and the
# link is to tenset:
$$rmEffects{'tile_dob_content'} = '';
$$rmEffects{'tile_dob_link'} = 'http://www.tenset.co.uk';
if (($strYear % 2) == 1 ) {
$$rmEffects{'tile_dob_inlinestyle_css'} =
'background-color: #00e0e0;';
# Set up an entry for the highlighting legend:
$$rmEffects{'tile_dob_legend'} =
$::g_q->escapeHTML("Born in an odd year");
} else {
$$rmEffects{'tile_dob_inlinestyle_css'} =
'background-color: #e000e0';
# Set up an entry for the highlighting legend:
$$rmEffects{'tile_dob_legend'} =
$::g_q->escapeHTML("Born in an even year");
}
}
}
# If the above code has not handled this highlighting definition itself,
# defer to the standard implementation:
if ($fUseStdImpl) {
&pdsHookStdImpl_Highlighting_GetForRecord(
$strTableSuffix, $rmHighlightingDef, $strContext, $rmEffects,
$rmFieldValues, $nPrimaryKey, $strFldPrefix, $rmState, $rmArgsEx);
}
}
This custom highlighting method uses the date of birth field ('A_DOB'). When Pedserve fetches data from the database, it does not automatically fetch all the fields - it only fetches those it needs. For this reason, when your custom highlighting method is selected, you need to take steps to ensure that Pedserve will pull any fields you need. You do this by reimplementing the hookHighlighting_GetExtraFlds hook:
Show/Hide Sample Code
# Hook function to return extra fields that are required by a given
# highlighting method.
#
# Arg 1 - table suffix
# Arg 2 - reference to map holding decoded highlight definition
# Arg 3 - context
# Arg 4 - field name prefix
# OPTIONAL
# Arg 4 - reference to map for future additional arguments; possibly undefined
sub hookHighlighting_GetExtraFlds {
my ($strTableSuffix, $rmHighlightingDef,
$strContext, $strFldPrefix, $rmArgsEx) = @_;
# You probably dont want to interfere with the correct working
# of pedserve's internally defined highlighting methods.
# So what you should do is make your highlighting definition
# identifiable - by including terms that you can test
# for here. Then you can defer to the default implementation
# when necessary.
my $fUseStdImpl = 1;
my $strReturn = '';
# Trivial example that checks for the term 'myhighlighting=yes'
# in the highlighting definition, and if present returns a specific
# field name. To use this, you would have to define a highlighting
# method during the script startup with a call to
# &pdsSetHighlightingDef() e.g.
# &pdsSetHighlightingDef('A_myhighlighting',
# 'label=Highlight DOB;myhighlighting=yes;');
# Note also the check against $strTableSuffix to ensure this is only
# used with animal records, and
# the check that this is not a pedserve-private definition:
if (!defined($$rmHighlightingDef{'pdsprivate'}) &&
$strTableSuffix eq 'A' &&
defined($$rmHighlightingDef{'myhighlighting'}) &&
$$rmHighlightingDef{'myhighlighting'} eq 'yes') {
# Dont defer to standard implementation below:
$fUseStdImpl = 0;
# Set the fields to return:
# (this example will use the date of birth field to apply specific
# highlights for given dates etc)
$strReturn = $strFldPrefix.'A_DOB';
}
# If the above code has not handled this highlighting definition itself,
# defer to the standard implementation:
if ($fUseStdImpl) {
$strReturn = &pdsHookStdImpl_Highlighting_GetExtraFlds($strTableSuffix,
$rmHighlightingDef, $strContext, $strFldPrefix, $rmArgsEx);
}
return $strReturn;
}
|
|
|

Record Highlighting - Other Decorations - Pedigree

Record Highlighting - Other Decorations - Search Results
|
This is a variation of the filled tile and text tile highlighting methods where, instead of Pedserve constructing the tile to 'enclose' your 'content' - colour and/or text - you supply the whole of the 'decoration' to be added to the record. Any such 'decoration' you supply is displayed in the same place as tiles would be. You need to reimplement the hookHighlighting_GetForRecord hook.
The example below shows the addition of a custom decoration highlight based on the date of birth field ('A_DOB'). It tests the birth year, and if it is in the 1970's, adds a 'bone' gif image to the record display; again, hardly a real world example but it shows the basics of getting the field data and using it to generate a highlight.
Note how the same highlighting code affects search results and pedigree pages in different ways. With a pedigree page, or any other place where a record is displayed as a plate, the decorations are added at the end of the record. But in search results pages, they are placed in a separate column to the left of the hit no. column.
Show/Hide Sample Code
# Hook function to apply highlighting for a record - storing
# the required highlighting decorations in a supplied map.
#
# Arg 1 - table suffix
# Arg 2 - reference to map holding decoded highlight definition
# Arg 3 - context
# Arg 4 - reference to map into which highlight effects are to be stored
# Arg 5 - reference to map of field values
# Arg 6 - primary key
# Arg 7 - field name prefix
# Arg 8 - reference to map into which highlighting state can be
# stored for the current panel
# OPTIONAL
# Arg 9 - reference to map for future additional arguments; possibly undefined
sub hookHighlighting_GetForRecord {
my ($strTableSuffix, $rmHighlightingDef, $strContext, $rmEffects,
$rmFieldValues, $nPrimaryKey, $strFldPrefix, $rmState, $rmArgsEx) = @_;
# You probably dont want to interfere with the correct working of
# pedserve's internally defined highlighting methods.
# So what you should do is make your highlighting definition
# identifiable - by including terms that you can test
# for here. Then you can defer to the default implementation when
# necessary.
my $fUseStdImpl = 1;
# Example that checks for the term 'myhighlighting=yes' in
# the highlighting definition, and if present handles it here.
# To use this, you would have to define a highlighting during
# the script startup with a call to &pdsSetHighlightingDef() e.g.
# &pdsSetHighlightingDef('A_myhighlighting',
# 'label=Highlight DOB;myhighlighting=yes;');
# Note also the check against $strTableSuffix to ensure this is
# only used with animal records, and the check that this is
# not a pedserve-private definition:
if (!defined($$rmHighlightingDef{'pdsprivate'}) &&
$strTableSuffix eq 'A' &&
defined($$rmHighlightingDef{'myhighlighting'}) &&
$$rmHighlightingDef{'myhighlighting'} eq 'yes') {
# Dont defer to standard implementation below:
$fUseStdImpl = 0;
# This demonstrates record-level highlighting by adding
# a 'bone icon' to the rendered output for a record.
# Extract the value of the date of birth field from the
# field results map:
my $date = $$rmFieldValues{$nPrimaryKey.':'.$strFldPrefix.'A_DOB'};
# If the DOB is valid and in the 1970's:
if (defined($date) && $date =~ m/^197.*/) {
# ... then we will decorate the
# record with a gif image:
$$rmEffects{'otherdecorations'} =
$::g_q->img({'-src' =>
&pdsMakeStaticFileURL('bone.gif')});
}
}
# If the above code has not handled this highlighting definition itself,
# defer to the standard implementation:
if ($fUseStdImpl) {
&pdsHookStdImpl_Highlighting_GetForRecord(
$strTableSuffix, $rmHighlightingDef, $strContext, $rmEffects,
$rmFieldValues, $nPrimaryKey, $strFldPrefix, $rmState, $rmArgsEx);
}
}
This custom highlighting method uses the date of birth field ('A_DOB'). When Pedserve fetches data from the database, it does not automatically fetch all the fields - it only fetches those it needs. For this reason, when your custom highlighting method is selected, you need to take steps to ensure that Pedserve will pull any fields you need. You do this by reimplementing the hookHighlighting_GetExtraFlds hook:
Show/Hide Sample Code
# Hook function to return extra fields that are required by a given
# highlighting method.
#
# Arg 1 - table suffix
# Arg 2 - reference to map holding decoded highlight definition
# Arg 3 - context
# Arg 4 - field name prefix
# OPTIONAL
# Arg 4 - reference to map for future additional arguments; possibly undefined
sub hookHighlighting_GetExtraFlds {
my ($strTableSuffix, $rmHighlightingDef,
$strContext, $strFldPrefix, $rmArgsEx) = @_;
# You probably dont want to interfere with the correct working
# of pedserve's internally defined highlighting methods.
# So what you should do is make your highlighting definition
# identifiable - by including terms that you can test
# for here. Then you can defer to the default implementation
# when necessary.
my $fUseStdImpl = 1;
my $strReturn = '';
# Trivial example that checks for the term 'myhighlighting=yes'
# in the highlighting definition, and if present returns a specific
# field name. To use this, you would have to define a highlighting
# method during the script startup with a call to
# &pdsSetHighlightingDef() e.g.
# &pdsSetHighlightingDef('A_myhighlighting',
# 'label=Highlight DOB;myhighlighting=yes;');
# Note also the check against $strTableSuffix to ensure this is only
# used with animal records, and
# the check that this is not a pedserve-private definition:
if (!defined($$rmHighlightingDef{'pdsprivate'}) &&
$strTableSuffix eq 'A' &&
defined($$rmHighlightingDef{'myhighlighting'}) &&
$$rmHighlightingDef{'myhighlighting'} eq 'yes') {
# Dont defer to standard implementation below:
$fUseStdImpl = 0;
# Set the fields to return:
# (this example will use the date of birth field to apply specific
# highlights for given dates etc)
$strReturn = $strFldPrefix.'A_DOB';
}
# If the above code has not handled this highlighting definition itself,
# defer to the standard implementation:
if ($fUseStdImpl) {
$strReturn = &pdsHookStdImpl_Highlighting_GetExtraFlds($strTableSuffix,
$rmHighlightingDef, $strContext, $strFldPrefix, $rmArgsEx);
}
return $strReturn;
}
|
|
|

Record Highlighting - Background Highlight - Pedigree

Record Highlighting - Background Highlight - Search Results
|
With the background colouring highlighting method, you supply an inline CSS style to be applied to the whole record. Whatever string you supply is inserted into 1 or more HTML tags that enclose all the HTML output for the record, using the style attribute.
Typically this is used to apply a visual effect to the background of the tag - applying a background color and/or image tile. However because all that Pedserve does with the text you supply is to place it within a style attribute, you could supply whatever (appropriate) CSS code you want.
The example below sets the background colour depending on the date of birth field ('A_DOB'). It tests the birth year, and if it is in the 1980's, returns a style string of background-color: #d0d080; which results in a yellow-green background; again, hardly a real world example but it shows the basics of getting the field data and using it to generate a highlight.
Note how the same highlighting code affects search results and pedigree pages in different ways. With a pedigree page, or any other place where a record is displayed as a plate, the whole 'cell' is highlighted. With search results pages, the whole record row is highlighted.
Show/Hide Sample Code
# Hook function to apply highlighting for a record - storing
# the required highlighting decorations in a supplied map.
#
# Arg 1 - table suffix
# Arg 2 - reference to map holding decoded highlight definition
# Arg 3 - context
# Arg 4 - reference to map into which highlight effects are to be stored
# Arg 5 - reference to map of field values
# Arg 6 - primary key
# Arg 7 - field name prefix
# Arg 8 - reference to map into which highlighting state can be
# stored for the current panel
# OPTIONAL
# Arg 9 - reference to map for future additional arguments; possibly undefined
sub hookHighlighting_GetForRecord {
my ($strTableSuffix, $rmHighlightingDef, $strContext, $rmEffects,
$rmFieldValues, $nPrimaryKey, $strFldPrefix, $rmState, $rmArgsEx) = @_;
# You probably dont want to interfere with the correct working of
# pedserve's internally defined highlighting methods.
# So what you should do is make your highlighting definition
# identifiable - by including terms that you can test
# for here. Then you can defer to the default implementation when
# necessary.
my $fUseStdImpl = 1;
# Example that checks for the term 'myhighlighting=yes' in
# the highlighting definition, and if present handles it here.
# To use this, you would have to define a highlighting during
# the script startup with a call to &pdsSetHighlightingDef() e.g.
# &pdsSetHighlightingDef('A_myhighlighting',
# 'label=Highlight DOB;myhighlighting=yes;');
# Note also the check against $strTableSuffix to ensure this is
# only used with animal records, and the check that this is
# not a pedserve-private definition:
if (!defined($$rmHighlightingDef{'pdsprivate'}) &&
$strTableSuffix eq 'A' &&
defined($$rmHighlightingDef{'myhighlighting'}) &&
$$rmHighlightingDef{'myhighlighting'} eq 'yes') {
# Dont defer to standard implementation below:
$fUseStdImpl = 0;
# EG4 This demonstrates record-level highlighting by applying
# a background color to the rendered output for a record.
# Extract the value of the date of birth field from the
# field results map:
my $date = $$rmFieldValues{$nPrimaryKey.':'.$strFldPrefix.'A_DOB'};
# If the DOB is valid and in the 1980's:
if (defined($date) && $date =~ m/^198.*/) {
# Set a CSS style for the field:
$$rmEffects{'inlinestyle_css'} =
'background-color: #d0d080;';
# Set up an entry for the highlighting legend:
$$rmEffects{'inlinestyle_legend'} =
$::g_q->escapeHTML("Born in the 1980's");
}
}
# If the above code has not handled this highlighting definition itself,
# defer to the standard implementation:
if ($fUseStdImpl) {
&pdsHookStdImpl_Highlighting_GetForRecord(
$strTableSuffix, $rmHighlightingDef, $strContext, $rmEffects,
$rmFieldValues, $nPrimaryKey, $strFldPrefix, $rmState, $rmArgsEx);
}
}
This custom highlighting method uses the date of birth field ('A_DOB'). When Pedserve fetches data from the database, it does not automatically fetch all the fields - it only fetches those it needs. For this reason, when your custom highlighting method is selected, you need to take steps to ensure that Pedserve will pull any fields you need. You do this by reimplementing the hookHighlighting_GetExtraFlds hook:
Show/Hide Sample Code
# Hook function to return extra fields that are required by a given
# highlighting method.
#
# Arg 1 - table suffix
# Arg 2 - reference to map holding decoded highlight definition
# Arg 3 - context
# Arg 4 - field name prefix
# OPTIONAL
# Arg 4 - reference to map for future additional arguments; possibly undefined
sub hookHighlighting_GetExtraFlds {
my ($strTableSuffix, $rmHighlightingDef,
$strContext, $strFldPrefix, $rmArgsEx) = @_;
# You probably dont want to interfere with the correct working
# of pedserve's internally defined highlighting methods.
# So what you should do is make your highlighting definition
# identifiable - by including terms that you can test
# for here. Then you can defer to the default implementation
# when necessary.
my $fUseStdImpl = 1;
my $strReturn = '';
# Trivial example that checks for the term 'myhighlighting=yes'
# in the highlighting definition, and if present returns a specific
# field name. To use this, you would have to define a highlighting
# method during the script startup with a call to
# &pdsSetHighlightingDef() e.g.
# &pdsSetHighlightingDef('A_myhighlighting',
# 'label=Highlight DOB;myhighlighting=yes;');
# Note also the check against $strTableSuffix to ensure this is only
# used with animal records, and
# the check that this is not a pedserve-private definition:
if (!defined($$rmHighlightingDef{'pdsprivate'}) &&
$strTableSuffix eq 'A' &&
defined($$rmHighlightingDef{'myhighlighting'}) &&
$$rmHighlightingDef{'myhighlighting'} eq 'yes') {
# Dont defer to standard implementation below:
$fUseStdImpl = 0;
# Set the fields to return:
# (this example will use the date of birth field to apply specific
# highlights for given dates etc)
$strReturn = $strFldPrefix.'A_DOB';
}
# If the above code has not handled this highlighting definition itself,
# defer to the standard implementation:
if ($fUseStdImpl) {
$strReturn = &pdsHookStdImpl_Highlighting_GetExtraFlds($strTableSuffix,
$rmHighlightingDef, $strContext, $strFldPrefix, $rmArgsEx);
}
return $strReturn;
}
|
|
|

Record Highlighting - Highlighting Records with Common Properties - Pedigree

Record Highlighting - Highlighting Records with Common Properties - Search Results
|
Sometimes you might want to examine all of the records visible on a page in order to determine a highlight effect. E.g. you might want to highlight records that have something in common.
To do this, you need to reimplement both the hookHighlighting_PrepareForRecordset and hookHighlighting_GetForRecord hooks.
The hookHighlighting_PrepareForRecordset hook is called once for the page, and is passed the primary keys of all the records on the page (i.e. their record IDs) plus a map containing all the field values for those records. Your code can then analyse the records to determine the highlights you want to add, and then store the results of this analysis - i.e. your highlighting 'state information' for all the records in a temporary map (also supplied as an argument). This map is then in turn passed to each subsequent call to hookHighlighting_GetForRecord, where your custom code retrieves the particular highlight needed for each record, and applies it.
This mechanism can be used to apply any of the highlighting visuals described on this page.
In the example below, it is used to highlight those animals that share the same birth year, using unique background colours.
Show/Hide Sample Code
# Hook function to prepare highlighting for a record set.
# This is called in a report that has highlighting support
# AFTER the records have been fetched from the db but BEFORE
# any output has occurred.
#
# This is the opportunity for any highlighting method that needs to
# 'see' all the records in order to determine highlighting.
# Ie highlighting that depends on the data of more than one record.
# E.g. is you wanted to apply a separate background
# colour to all animals that have a given attribute in common.
# E.g. all animals of the same colour, etc.
#
# Arg 1 - table suffix
# Arg 2 - reference to map holding decoded highlight definition
# Arg 3 - context
# Arg 4 - reference to map of field values
# Arg 5 - reference to array holding ordered keys of the record set
# Arg 6 - field name prefix
# Arg 7 - reference to map into which highlighting state can be stored
# OPTIONAL
# Arg 8 - reference to map for future additional arguments; possibly undefined
sub hookHighlighting_PrepareForRecordset {
my ($strTableSuffix, $rmHighlightingDef, $strContext, $rmFieldValues,
$raKeys, $strFldPrefix, $rmState, $rmArgsEx) = @_;
# You probably dont want to interfere with the correct working of
# pedserve's internally defined highlighting methods.
# So what you should do is make your highlighting definition
# identifiable - by including terms that you can test
# for here. Then you can defer to the default implementation when
# necessary.
my $fUseStdImpl = 1;
# Trivial example that checks for the term 'myhighlighting=yes'
# in the highlighting definition, and if present handles it here.
# To use this, you would have to define a highlighting during the
# script startup with a call to &pdsSetHighlightingDef() e.g.
# &pdsSetHighlightingDef('A_myhighlighting',
# 'label=Highlight DOB;myhighlighting=yes;');
# Note also the check against $strTableSuffix to ensure this is
# only used with animal records, and the check that this is not
# a pedserve-private definition:
if (!defined($$rmHighlightingDef{'pdsprivate'}) &&
$strTableSuffix eq 'A' &&
defined($$rmHighlightingDef{'myhighlighting'}) &&
$$rmHighlightingDef{'myhighlighting'} eq 'yes') {
# Dont defer to standard implementation below:
$fUseStdImpl = 0;
# This example is going to apply a unique background colour
# to all animals that share the same year of birth.
# You could use the same method e.g. to a colour field to
# highlight all animals with the same coat colour.
my %mBirthYearOccurrences = ();
for (my $i = 0; $i < scalar(@$raKeys); $i++) {
my $nPrimaryKey = $$raKeys[$i];
# Extract the date of birth field value from the
# field results map:
my $date = $$rmFieldValues{$nPrimaryKey.':'.$strFldPrefix.'A_DOB'};
# Skip if there is none:
next if !defined($date) || $date eq '';
# Extract the year part:
my $strBirthYear = substr($date, 0, 4);
# Increment a count of the no. of times we have seen
# this birth year:
$mBirthYearOccurrences{$strBirthYear}++;
}
# Now we create a unique background style for each birth
# year that's been seen twice or more in the data:
my $nNextStyle = 0;
foreach my $strBirthYear (keys(%mBirthYearOccurrences)) {
next if $mBirthYearOccurrences{$strBirthYear} <= 1;
# Create a unique background CSS style, and store it
# in the supplied state info map, keyed by the birth year:
$$rmState{$strBirthYear} = &pdsGetUniqueBackgroundInlineStyle($nNextStyle++);
}
# Thats all we do here. Now turn to the related code in
# &hookHighlighting_GetForRecord(), which is where the
# unique backgrounds we have created get used.
}
# If the above code has not handled this highlighting definition itself,
# defer to the standard implementation:
if ($fUseStdImpl) {
&pdsHookStdImpl_Highlighting_PrepareForRecordset($strTableSuffix,
$rmHighlightingDef, $strContext, $rmFieldValues,
$raKeys, $strFldPrefix, $rmState, $rmArgsEx);
}
}
# Hook function to apply highlighting for a record - storing
# the required highlighting decorations in a supplied map.
#
# Arg 1 - table suffix
# Arg 2 - reference to map holding decoded highlight definition
# Arg 3 - context
# Arg 4 - reference to map into which highlight effects are to be stored
# Arg 5 - reference to map of field values
# Arg 6 - primary key
# Arg 7 - field name prefix
# Arg 8 - reference to map into which highlighting state can be
# stored for the current panel
# OPTIONAL
# Arg 9 - reference to map for future additional arguments; possibly undefined
sub hookHighlighting_GetForRecord {
my ($strTableSuffix, $rmHighlightingDef, $strContext, $rmEffects,
$rmFieldValues, $nPrimaryKey, $strFldPrefix, $rmState, $rmArgsEx) = @_;
# You probably dont want to interfere with the correct working of
# pedserve's internally defined highlighting methods.
# So what you should do is make your highlighting definition
# identifiable - by including terms that you can test
# for here. Then you can defer to the default implementation when
# necessary.
my $fUseStdImpl = 1;
# Example that checks for the term 'myhighlighting=yes' in
# the highlighting definition, and if present handles it here.
# To use this, you would have to define a highlighting during
# the script startup with a call to &pdsSetHighlightingDef() e.g.
# &pdsSetHighlightingDef('A_myhighlighting',
# 'label=Highlight DOB;myhighlighting=yes;');
# Note also the check against $strTableSuffix to ensure this is
# only used with animal records, and the check that this is
# not a pedserve-private definition:
if (!defined($$rmHighlightingDef{'pdsprivate'}) &&
$strTableSuffix eq 'A' &&
defined($$rmHighlightingDef{'myhighlighting'}) &&
$$rmHighlightingDef{'myhighlighting'} eq 'yes') {
# Dont defer to standard implementation below:
$fUseStdImpl = 0;
# This demonstrates record-level highlighting by giving
# a separate background colour to animals that share the same
# birth year.
# Extract the date of birth field value from the
# field results map:
my $date = $$rmFieldValues{$nPrimaryKey.':'.$strFldPrefix.'A_DOB'};
if (defined($date) && $date ne '') {
# This animal has its DOB set.
# Extract the year part:
my $strYear = substr($date, 0, 4);
# Get any stored inline background colour
# for this birth year:
my $strInlineStyle = $$rmState{$strYear};
# Store it in the effects map if we have one:
if (defined($strInlineStyle) && $strInlineStyle ne '') {
$$rmEffects{'inlinestyle_css'} = $strInlineStyle;
# Set up an entry for the highlighting legend:
$$rmEffects{'inlinestyle_legend'} =
$::g_q->escapeHTML("Born in $strYear");
}
}
}
# If the above code has not handled this highlighting definition itself,
# defer to the standard implementation:
if ($fUseStdImpl) {
&pdsHookStdImpl_Highlighting_GetForRecord(
$strTableSuffix, $rmHighlightingDef, $strContext, $rmEffects,
$rmFieldValues, $nPrimaryKey, $strFldPrefix, $rmState, $rmArgsEx);
}
}
This custom highlighting method uses the date of birth field ('A_DOB'). When Pedserve fetches data from the database, it does not automatically fetch all the fields - it only fetches those it needs. For this reason, when your custom highlighting method is selected, you need to take steps to ensure that Pedserve will pull any fields you need. You do this by reimplementing the hookHighlighting_GetExtraFlds hook:
Show/Hide Sample Code
# Hook function to return extra fields that are required by a given
# highlighting method.
#
# Arg 1 - table suffix
# Arg 2 - reference to map holding decoded highlight definition
# Arg 3 - context
# Arg 4 - field name prefix
# OPTIONAL
# Arg 4 - reference to map for future additional arguments; possibly undefined
sub hookHighlighting_GetExtraFlds {
my ($strTableSuffix, $rmHighlightingDef,
$strContext, $strFldPrefix, $rmArgsEx) = @_;
# You probably dont want to interfere with the correct working
# of pedserve's internally defined highlighting methods.
# So what you should do is make your highlighting definition
# identifiable - by including terms that you can test
# for here. Then you can defer to the default implementation
# when necessary.
my $fUseStdImpl = 1;
my $strReturn = '';
# Trivial example that checks for the term 'myhighlighting=yes'
# in the highlighting definition, and if present returns a specific
# field name. To use this, you would have to define a highlighting
# method during the script startup with a call to
# &pdsSetHighlightingDef() e.g.
# &pdsSetHighlightingDef('A_myhighlighting',
# 'label=Highlight DOB;myhighlighting=yes;');
# Note also the check against $strTableSuffix to ensure this is only
# used with animal records, and
# the check that this is not a pedserve-private definition:
if (!defined($$rmHighlightingDef{'pdsprivate'}) &&
$strTableSuffix eq 'A' &&
defined($$rmHighlightingDef{'myhighlighting'}) &&
$$rmHighlightingDef{'myhighlighting'} eq 'yes') {
# Dont defer to standard implementation below:
$fUseStdImpl = 0;
# Set the fields to return:
# (this example will use the date of birth field to apply specific
# highlights for given dates etc)
$strReturn = $strFldPrefix.'A_DOB';
}
# If the above code has not handled this highlighting definition itself,
# defer to the standard implementation:
if ($fUseStdImpl) {
$strReturn = &pdsHookStdImpl_Highlighting_GetExtraFlds($strTableSuffix,
$rmHighlightingDef, $strContext, $strFldPrefix, $rmArgsEx);
}
return $strReturn;
}
|
|
|

Record Highlighting - Text Emphasis - Pedigree

Record Highlighting - Text Emphasis - Search Results
|
With the text emphasis highlighting method, you return a value that Pedserve uses to apply various text effects to the whole record.
The following table lists the available text effects. These may be combined using the bit-wise or operator ('|').
| Effect |
Value |
$::c_EMPH_BOLD |
Add bold emphasis |
$::c_EMPH_ITALIC |
Add italic emphasis |
$::c_EMPH_CODE |
Add 'code' emphasis (typically a fixed-width font) |
$::c_EMPH_BIG |
Make the text a bit bigger |
$::c_EMPH_ERROR |
Apply 'error' emphasis - typically formatting in red. |
$::c_EMPH_WARNING |
Apply 'warning' emphasis - typically formatting in red. |
$::c_EMPH_SINGLEQUOTED |
Enclose the text in single quotes |
$::c_EMPH_DOUBLEQUOTED |
Enclose the text in double quotes |
(You can also redefine the actual visual effect of most of these, via CSS. E.g. the $::c_EMPH_BOLD code is applied using a <span> tag with a class attribute of pds-emph-bold-span. So to redefine what 'bold' means, all you need to do is edit the stylesheet and change the pds-emph-bold-span entry).
The example below sets the text emphasis depending on the date of birth field ('A_DOB'). It tests the birth year, and if it is in the 1970's, returns a text emphasis code of $::c_EMPH_ITALIC to italicise the text; again, hardly a real world example but it shows the basics of getting the field data and using it to generate a highlight.
Show/Hide Sample Code
# Hook function to apply highlighting for a record - storing
# the required highlighting decorations in a supplied map.
#
# Arg 1 - table suffix
# Arg 2 - reference to map holding decoded highlight definition
# Arg 3 - context
# Arg 4 - reference to map into which highlight effects are to be stored
# Arg 5 - reference to map of field values
# Arg 6 - primary key
# Arg 7 - field name prefix
# Arg 8 - reference to map into which highlighting state can be
# stored for the current panel
# OPTIONAL
# Arg 9 - reference to map for future additional arguments; possibly undefined
sub hookHighlighting_GetForRecord {
my ($strTableSuffix, $rmHighlightingDef, $strContext, $rmEffects,
$rmFieldValues, $nPrimaryKey, $strFldPrefix, $rmState, $rmArgsEx) = @_;
# You probably dont want to interfere with the correct working of
# pedserve's internally defined highlighting methods.
# So what you should do is make your highlighting definition
# identifiable - by including terms that you can test
# for here. Then you can defer to the default implementation when
# necessary.
my $fUseStdImpl = 1;
# Example that checks for the term 'myhighlighting=yes' in
# the highlighting definition, and if present handles it here.
# To use this, you would have to define a highlighting during
# the script startup with a call to &pdsSetHighlightingDef() e.g.
# &pdsSetHighlightingDef('A_myhighlighting',
# 'label=Highlight DOB;myhighlighting=yes;');
# Note also the check against $strTableSuffix to ensure this is
# only used with animal records, and the check that this is
# not a pedserve-private definition:
if (!defined($$rmHighlightingDef{'pdsprivate'}) &&
$strTableSuffix eq 'A' &&
defined($$rmHighlightingDef{'myhighlighting'}) &&
$$rmHighlightingDef{'myhighlighting'} eq 'yes') {
# Dont defer to standard implementation below:
$fUseStdImpl = 0;
# This demonstrates record-level highlighting by adding
# text emphasis to the rendered output for a record.
# Extract the value of the date of birth field from the
# field results map:
my $date = $$rmFieldValues{$nPrimaryKey.':'.$strFldPrefix.'A_DOB'};
# If the DOB is valid and in the 1970's:
if (defined($date) && $date =~ m/^197.*/) {
# ... then we will emphasis the whole
# record with italics:
$$rmEffects{'emphasis_code'} = $::c_EMPH_ITALIC;
# Set up an entry for the highlighting legend:
$$rmEffects{'emphasis_legend'} =
$::g_q->escapeHTML("Born in the 1970's");
}
}
# If the above code has not handled this highlighting definition itself,
# defer to the standard implementation:
if ($fUseStdImpl) {
&pdsHookStdImpl_Highlighting_GetForRecord(
$strTableSuffix, $rmHighlightingDef, $strContext, $rmEffects,
$rmFieldValues, $nPrimaryKey, $strFldPrefix, $rmState, $rmArgsEx);
}
}
This custom highlighting method uses the date of birth field ('A_DOB'). When Pedserve fetches data from the database, it does not automatically fetch all the fields - it only fetches those it needs. For this reason, when your custom highlighting method is selected, you need to take steps to ensure that Pedserve will pull any fields you need. You do this by reimplementing the hookHighlighting_GetExtraFlds hook:
Show/Hide Sample Code
# Hook function to return extra fields that are required by a given
# highlighting method.
#
# Arg 1 - table suffix
# Arg 2 - reference to map holding decoded highlight definition
# Arg 3 - context
# Arg 4 - field name prefix
# OPTIONAL
# Arg 4 - reference to map for future additional arguments; possibly undefined
sub hookHighlighting_GetExtraFlds {
my ($strTableSuffix, $rmHighlightingDef,
$strContext, $strFldPrefix, $rmArgsEx) = @_;
# You probably dont want to interfere with the correct working
# of pedserve's internally defined highlighting methods.
# So what you should do is make your highlighting definition
# identifiable - by including terms that you can test
# for here. Then you can defer to the default implementation
# when necessary.
my $fUseStdImpl = 1;
my $strReturn = '';
# Trivial example that checks for the term 'myhighlighting=yes'
# in the highlighting definition, and if present returns a specific
# field name. To use this, you would have to define a highlighting
# method during the script startup with a call to
# &pdsSetHighlightingDef() e.g.
# &pdsSetHighlightingDef('A_myhighlighting',
# 'label=Highlight DOB;myhighlighting=yes;');
# Note also the check against $strTableSuffix to ensure this is only
# used with animal records, and
# the check that this is not a pedserve-private definition:
if (!defined($$rmHighlightingDef{'pdsprivate'}) &&
$strTableSuffix eq 'A' &&
defined($$rmHighlightingDef{'myhighlighting'}) &&
$$rmHighlightingDef{'myhighlighting'} eq 'yes') {
# Dont defer to standard implementation below:
$fUseStdImpl = 0;
# Set the fields to return:
# (this example will use the date of birth field to apply specific
# highlights for given dates etc)
$strReturn = $strFldPrefix.'A_DOB';
}
# If the above code has not handled this highlighting definition itself,
# defer to the standard implementation:
if ($fUseStdImpl) {
$strReturn = &pdsHookStdImpl_Highlighting_GetExtraFlds($strTableSuffix,
$rmHighlightingDef, $strContext, $strFldPrefix, $rmArgsEx);
}
return $strReturn;
}
|
|
|

Record Highlighting - Pre/Post Custom HTML - Pedigree

Record Highlighting - Pre/Post Custom HTML - Search Results
|
With the record-level 'Pre/Post HTML' highlighting method, you supply HTML snippets that Pedserve will use to enclose the HTML of the record. Use this as a means to applying any other HTML structure/effects you want.
The example below encloses the record HTML in a <font> tag, depending on the date of birth field ('A_DOB'). It tests the birth year, and if it is in the 1970's, sets a pre-HTML string of <font face="Times, serif">, and a post-HTML string of </font>. The result is that a different font is used for the record; again, hardly a real world example but it shows the basics of getting the field data and using it to generate a highlight.
Show/Hide Sample Code
# Hook function to apply highlighting for a record - storing
# the required highlighting decorations in a supplied map.
#
# Arg 1 - table suffix
# Arg 2 - reference to map holding decoded highlight definition
# Arg 3 - context
# Arg 4 - reference to map into which highlight effects are to be stored
# Arg 5 - reference to map of field values
# Arg 6 - primary key
# Arg 7 - field name prefix
# Arg 8 - reference to map into which highlighting state can be
# stored for the current panel
# OPTIONAL
# Arg 9 - reference to map for future additional arguments; possibly undefined
sub hookHighlighting_GetForRecord {
my ($strTableSuffix, $rmHighlightingDef, $strContext, $rmEffects,
$rmFieldValues, $nPrimaryKey, $strFldPrefix, $rmState, $rmArgsEx) = @_;
# You probably dont want to interfere with the correct working of
# pedserve's internally defined highlighting methods.
# So what you should do is make your highlighting definition
# identifiable - by including terms that you can test
# for here. Then you can defer to the default implementation when
# necessary.
my $fUseStdImpl = 1;
# Example that checks for the term 'myhighlighting=yes' in
# the highlighting definition, and if present handles it here.
# To use this, you would have to define a highlighting during
# the script startup with a call to &pdsSetHighlightingDef() e.g.
# &pdsSetHighlightingDef('A_myhighlighting',
# 'label=Highlight DOB;myhighlighting=yes;');
# Note also the check against $strTableSuffix to ensure this is
# only used with animal records, and the check that this is
# not a pedserve-private definition:
if (!defined($$rmHighlightingDef{'pdsprivate'}) &&
$strTableSuffix eq 'A' &&
defined($$rmHighlightingDef{'myhighlighting'}) &&
$$rmHighlightingDef{'myhighlighting'} eq 'yes') {
# Dont defer to standard implementation below:
$fUseStdImpl = 0;
# This demonstrates record-level highlighting by adding
# custom pre- and post- html to the rendered output for a record.
# We cause the output to be rendered in a different typeface.
# Extract the value of the date of birth field from the
# field results map:
my $date = $$rmFieldValues{$nPrimaryKey.':'.$strFldPrefix.'A_DOB'};
# If the DOB is valid and in the 1970's:
if (defined($date) && $date =~ m/^197.*/) {
# ... then we will output the whole
# record with Times font:
$$rmEffects{'customhtml_pre'} = '<font face="Times, serif">';
$$rmEffects{'customhtml_post'} = '</font>';
# Set up an entry for the highlighting legend.
$$rmEffects{'customhtml_legend'} =
$::g_q->escapeHTML("Born in the 1970's");
}
}
# If the above code has not handled this highlighting definition itself,
# defer to the standard implementation:
if ($fUseStdImpl) {
&pdsHookStdImpl_Highlighting_GetForRecord(
$strTableSuffix, $rmHighlightingDef, $strContext, $rmEffects,
$rmFieldValues, $nPrimaryKey, $strFldPrefix, $rmState, $rmArgsEx);
}
}
This custom highlighting method uses the date of birth field ('A_DOB'). When Pedserve fetches data from the database, it does not automatically fetch all the fields - it only fetches those it needs. For this reason, when your custom highlighting method is selected, you need to take steps to ensure that Pedserve will pull any fields you need. You do this by reimplementing the hookHighlighting_GetExtraFlds hook:
Show/Hide Sample Code
# Hook function to return extra fields that are required by a given
# highlighting method.
#
# Arg 1 - table suffix
# Arg 2 - reference to map holding decoded highlight definition
# Arg 3 - context
# Arg 4 - field name prefix
# OPTIONAL
# Arg 4 - reference to map for future additional arguments; possibly undefined
sub hookHighlighting_GetExtraFlds {
my ($strTableSuffix, $rmHighlightingDef,
$strContext, $strFldPrefix, $rmArgsEx) = @_;
# You probably dont want to interfere with the correct working
# of pedserve's internally defined highlighting methods.
# So what you should do is make your highlighting definition
# identifiable - by including terms that you can test
# for here. Then you can defer to the default implementation
# when necessary.
my $fUseStdImpl = 1;
my $strReturn = '';
# Trivial example that checks for the term 'myhighlighting=yes'
# in the highlighting definition, and if present returns a specific
# field name. To use this, you would have to define a highlighting
# method during the script startup with a call to
# &pdsSetHighlightingDef() e.g.
# &pdsSetHighlightingDef('A_myhighlighting',
# 'label=Highlight DOB;myhighlighting=yes;');
# Note also the check against $strTableSuffix to ensure this is only
# used with animal records, and
# the check that this is not a pedserve-private definition:
if (!defined($$rmHighlightingDef{'pdsprivate'}) &&
$strTableSuffix eq 'A' &&
defined($$rmHighlightingDef{'myhighlighting'}) &&
$$rmHighlightingDef{'myhighlighting'} eq 'yes') {
# Dont defer to standard implementation below:
$fUseStdImpl = 0;
# Set the fields to return:
# (this example will use the date of birth field to apply specific
# highlights for given dates etc)
$strReturn = $strFldPrefix.'A_DOB';
}
# If the above code has not handled this highlighting definition itself,
# defer to the standard implementation:
if ($fUseStdImpl) {
$strReturn = &pdsHookStdImpl_Highlighting_GetExtraFlds($strTableSuffix,
$rmHighlightingDef, $strContext, $strFldPrefix, $rmArgsEx);
}
return $strReturn;
}
|
|
|

Field Highlighting - Filled Tile Highlight - Pedigree

Field Highlighting - Filled Tile Highlight - Search Results
|
In this form of highlighting, you specify a coloured tile that is used to decorate an individual field within a record. You need to reimplement the hookHighlighting_GetForField hook.
This is very similar to record-level filled tile highlighting; the only difference is where the tile is placed - adjacent to the field itself. In pedigrees and other plate-based displays, it looks very similar. But in search results screens the tile is placed to the right of the field value column, not in a separate column to the left.
The example below shows the addition of a filled tile highlight based on the date of birth field ('A_DOB'). It shows a different colour being used for odd and even birth years; hardly a real world example but it shows the basics of getting the field data and using it to generate a highlight.
Note also the legend that appears underneath the page content - telling the user what the colours mean for each field.
Show/Hide Sample Code
# Hook function to determine highlighting for a specific
# field within a record - storing the required highlighting
# decorations in a supplied map.
#
# Arg 1 - table suffix
# Arg 2 - reference to map holding decoded highlight definition
# Arg 3 - context
# Arg 4 - reference to map into which highlight effects are to be stored
# Arg 5 - reference to map of field values
# Arg 6 - primary key
# Arg 7 - field name prefix
# Arg 8 - full field name
# Arg 9 - reference to map into which highlighting state can be stored
# for the current panel
# OPTIONAL
# Arg 10 - reference to map for future additional arguments; possibly undefined
sub hookHighlighting_GetForField {
my ($strTableSuffix, $rmHighlightingDef, $strContext, $rmEffects,
$rmFieldValues, $nPrimaryKey, $strFldPrefix, $strFullFldName,
$rmState, $rmArgsEx) = @_;
# You probably dont want to interfere with the correct working of
# pedserve's internally defined highlighting methods. So what you
# should do is make your highlighting definition identifiable
# - by including terms that you can test for here. Then you can
# defer to the default implementation when necessary.
my $fUseStdImpl = 1;
# Example that checks for the term 'myhighlighting=yes'
# in the highlighting definition, and if present handles it here.
# To use this, you would have to define a highlighting during the
# script startup with a call to &pdsSetHighlightingDef() e.g.
# &pdsSetHighlightingDef('A_myhighlighting',
# 'label=Highlight DOB;myhighlighting=yes;');
# Note also the check against $strTableSuffix to ensure this is only
# used with animal records, and the check that this is not a
# pedserve-private definition:
if (!defined($$rmHighlightingDef{'pdsprivate'}) &&
$strTableSuffix eq 'A' &&
defined($$rmHighlightingDef{'myhighlighting'}) &&
$$rmHighlightingDef{'myhighlighting'} eq 'yes') {
# Dont defer to standard implementation below:
$fUseStdImpl = 0;
# This demonstrates highlighting by adding a 'tile' to the
# rendered output for a field. A tile is a small coloured rectangle
# placed next to the field value. The tile can contain supplied text,
# or can be blank. You can control the colour of the tile etc by
# setting an inline css style. You can also make the tile link to a
# supplied URL.
if ($strFullFldName eq $strFldPrefix.'A_DOB') {
# This is the date of birth field.
# Extract the actual value of the field from the field results map:
my $date = $$rmFieldValues{$nPrimaryKey.':'.$strFldPrefix.'A_DOB'};
if (defined($date) && $date ne '') {
# This animal has its DOB set.
# Extract the year part:
my $strYear = substr($date, 0, 4);
# Add a tile where the content is the year, the colour is red
# or green depending on whether the year is odd or even, and
# the link is to google:
$$rmEffects{'tile_dob_content'} = $strYear;
if (($strYear % 2) == 1 ) {
$$rmEffects{'tile_dob_inlinestyle_css'} =
'background-color: green;';
# Set up an entry for the highlighting legend:
$$rmEffects{'tile_dob_legend'} =
$::g_q->escapeHTML("Born in an odd year");
} else {
$$rmEffects{'tile_dob_inlinestyle_css'} =
'background-color: red';
# Set up an entry for the highlighting legend:
$$rmEffects{'tile_dob_legend'} =
$::g_q->escapeHTML("Born in an even year");
}
$$rmEffects{'tile_dob_link'} = 'http://www.google.com';
}
}
}
# If the above code has not handled this highlighting definition
# itself, defer to the standard implementation:
if ($fUseStdImpl) {
&pdsHookStdImpl_Highlighting_GetForField(
$strTableSuffix, $rmHighlightingDef, $strContext, $rmEffects,
$rmFieldValues, $nPrimaryKey, $strFldPrefix, $strFullFldName,
$rmState, $rmArgsEx);
}
}
This custom highlighting method uses the date of birth field ('A_DOB'). When Pedserve fetches data from the database, it does not automatically fetch all the fields - it only fetches those it needs. For this reason, when your custom highlighting method is selected, you need to take steps to ensure that Pedserve will pull any fields you need. You do this by reimplementing the hookHighlighting_GetExtraFlds hook:
Show/Hide Sample Code
# Hook function to return extra fields that are required by a given
# highlighting method.
#
# Arg 1 - table suffix
# Arg 2 - reference to map holding decoded highlight definition
# Arg 3 - context
# Arg 4 - field name prefix
# OPTIONAL
# Arg 4 - reference to map for future additional arguments; possibly undefined
sub hookHighlighting_GetExtraFlds {
my ($strTableSuffix, $rmHighlightingDef,
$strContext, $strFldPrefix, $rmArgsEx) = @_;
# You probably dont want to interfere with the correct working
# of pedserve's internally defined highlighting methods.
# So what you should do is make your highlighting definition
# identifiable - by including terms that you can test
# for here. Then you can defer to the default implementation
# when necessary.
my $fUseStdImpl = 1;
my $strReturn = '';
# Trivial example that checks for the term 'myhighlighting=yes'
# in the highlighting definition, and if present returns a specific
# field name. To use this, you would have to define a highlighting
# method during the script startup with a call to
# &pdsSetHighlightingDef() e.g.
# &pdsSetHighlightingDef('A_myhighlighting',
# 'label=Highlight DOB;myhighlighting=yes;');
# Note also the check against $strTableSuffix to ensure this is only
# used with animal records, and
# the check that this is not a pedserve-private definition:
if (!defined($$rmHighlightingDef{'pdsprivate'}) &&
$strTableSuffix eq 'A' &&
defined($$rmHighlightingDef{'myhighlighting'}) &&
$$rmHighlightingDef{'myhighlighting'} eq 'yes') {
# Dont defer to standard implementation below:
$fUseStdImpl = 0;
# Set the fields to return:
# (this example will use the date of birth field to apply specific
# highlights for given dates etc)
$strReturn = $strFldPrefix.'A_DOB';
}
# If the above code has not handled this highlighting definition itself,
# defer to the standard implementation:
if ($fUseStdImpl) {
$strReturn = &pdsHookStdImpl_Highlighting_GetExtraFlds($strTableSuffix,
$rmHighlightingDef, $strContext, $strFldPrefix, $rmArgsEx);
}
return $strReturn;
}
|
|
|

Field Highlighting - Text Tile Highlight - Pedigree

Field Highlighting - Text Tile Highlight - Search Results
|
This is a variation of the filled tile field highlighting.
In this form of highlighting, you specify a coloured tile that is used to decorate the field, but you also specify HTML content that is to be displayed within the tile. Its entirely up to you what you use here, but typically it will be an image, or a word, etc. You need to reimplement the hookHighlighting_GetForField hook.
This is very similar to record-level text tile highlighting; the only difference is where the tile is placed - adjacent to the field itself. In pedigrees and other plate-based displays, it looks very similar. But in search results screens the tile is placed to the right of the field value column, not in a separate column to the left.
The example below shows the addition of a text tile highlight based on the date of birth field ('A_DOB'). It uses different colours & labels for odd and even birth years; again, hardly a real world example but it shows the basics of getting the field data and using it to generate a highlight.
Show/Hide Sample Code
# Hook function to determine highlighting for a specific
# field within a record - storing the required highlighting
# decorations in a supplied map.
#
# Arg 1 - table suffix
# Arg 2 - reference to map holding decoded highlight definition
# Arg 3 - context
# Arg 4 - reference to map into which highlight effects are to be stored
# Arg 5 - reference to map of field values
# Arg 6 - primary key
# Arg 7 - field name prefix
# Arg 8 - full field name
# Arg 9 - reference to map into which highlighting state can be stored
# for the current panel
# OPTIONAL
# Arg 10 - reference to map for future additional arguments; possibly undefined
sub hookHighlighting_GetForField {
my ($strTableSuffix, $rmHighlightingDef, $strContext, $rmEffects,
$rmFieldValues, $nPrimaryKey, $strFldPrefix, $strFullFldName,
$rmState, $rmArgsEx) = @_;
# You probably dont want to interfere with the correct working of
# pedserve's internally defined highlighting methods. So what you
# should do is make your highlighting definition identifiable
# - by including terms that you can test for here. Then you can
# defer to the default implementation when necessary.
my $fUseStdImpl = 1;
# Example that checks for the term 'myhighlighting=yes'
# in the highlighting definition, and if present handles it here.
# To use this, you would have to define a highlighting during the
# script startup with a call to &pdsSetHighlightingDef() e.g.
# &pdsSetHighlightingDef('A_myhighlighting',
# 'label=Highlight DOB;myhighlighting=yes;');
# Note also the check against $strTableSuffix to ensure this is only
# used with animal records, and the check that this is not a
# pedserve-private definition:
if (!defined($$rmHighlightingDef{'pdsprivate'}) &&
$strTableSuffix eq 'A' &&
defined($$rmHighlightingDef{'myhighlighting'}) &&
$$rmHighlightingDef{'myhighlighting'} eq 'yes') {
# Dont defer to standard implementation below:
$fUseStdImpl = 0;
# This is identical to the above example, except that
# the highlight tile is generated using an <img> tag
# rather than <span>ned text.
if ($strFullFldName eq $strFldPrefix.'A_DOB') {
# This is the date of birth field.
# Extract the actual value of the field from the field results map:
my $date = $$rmFieldValues{$nPrimaryKey.':'.$strFldPrefix.'A_DOB'};
if (defined($date) && $date ne '') {
# This animal has its DOB set.
# Extract the year part:
my $strYear = substr($date, 0, 4);
# Add a 'blank icon' tile, the colour is red or green
# depending on whether the year is odd or even, and
# the link is to google:
$$rmEffects{'tile_dob_content'} = '';
if (($strYear % 2) == 1 ) {
$$rmEffects{'tile_dob_inlinestyle_css'} =
'background-color: green;';
# Set up an entry for the highlighting legend:
$$rmEffects{'tile_dob_legend'} =
$::g_q->escapeHTML("Born in an odd year");
} else {
$$rmEffects{'tile_dob_inlinestyle_css'} =
'background-color: red';
# Set up an entry for the highlighting legend:
$$rmEffects{'tile_dob_legend'} =
$::g_q->escapeHTML("Born in an even year");
}
$$rmEffects{'tile_dob_link'} = 'http://www.google.com';
}
}
}
# If the above code has not handled this highlighting definition
# itself, defer to the standard implementation:
if ($fUseStdImpl) {
&pdsHookStdImpl_Highlighting_GetForField(
$strTableSuffix, $rmHighlightingDef, $strContext, $rmEffects,
$rmFieldValues, $nPrimaryKey, $strFldPrefix, $strFullFldName,
$rmState, $rmArgsEx);
}
}
This custom highlighting method uses the date of birth field ('A_DOB'). When Pedserve fetches data from the database, it does not automatically fetch all the fields - it only fetches those it needs. For this reason, when your custom highlighting method is selected, you need to take steps to ensure that Pedserve will pull any fields you need. You do this by reimplementing the hookHighlighting_GetExtraFlds hook:
Show/Hide Sample Code
# Hook function to return extra fields that are required by a given
# highlighting method.
#
# Arg 1 - table suffix
# Arg 2 - reference to map holding decoded highlight definition
# Arg 3 - context
# Arg 4 - field name prefix
# OPTIONAL
# Arg 4 - reference to map for future additional arguments; possibly undefined
sub hookHighlighting_GetExtraFlds {
my ($strTableSuffix, $rmHighlightingDef,
$strContext, $strFldPrefix, $rmArgsEx) = @_;
# You probably dont want to interfere with the correct working
# of pedserve's internally defined highlighting methods.
# So what you should do is make your highlighting definition
# identifiable - by including terms that you can test
# for here. Then you can defer to the default implementation
# when necessary.
my $fUseStdImpl = 1;
my $strReturn = '';
# Trivial example that checks for the term 'myhighlighting=yes'
# in the highlighting definition, and if present returns a specific
# field name. To use this, you would have to define a highlighting
# method during the script startup with a call to
# &pdsSetHighlightingDef() e.g.
# &pdsSetHighlightingDef('A_myhighlighting',
# 'label=Highlight DOB;myhighlighting=yes;');
# Note also the check against $strTableSuffix to ensure this is only
# used with animal records, and
# the check that this is not a pedserve-private definition:
if (!defined($$rmHighlightingDef{'pdsprivate'}) &&
$strTableSuffix eq 'A' &&
defined($$rmHighlightingDef{'myhighlighting'}) &&
$$rmHighlightingDef{'myhighlighting'} eq 'yes') {
# Dont defer to standard implementation below:
$fUseStdImpl = 0;
# Set the fields to return:
# (this example will use the date of birth field to apply specific
# highlights for given dates etc)
$strReturn = $strFldPrefix.'A_DOB';
}
# If the above code has not handled this highlighting definition itself,
# defer to the standard implementation:
if ($fUseStdImpl) {
$strReturn = &pdsHookStdImpl_Highlighting_GetExtraFlds($strTableSuffix,
$rmHighlightingDef, $strContext, $strFldPrefix, $rmArgsEx);
}
return $strReturn;
}
|
|
|

Field Highlighting - Other Decorations - Pedigree

Field Highlighting - Other Decorations - Search Results
|
This is a variation of the filled tile and text tile highlighting methods where, instead of Pedserve constructing the tile to 'enclose' your 'content' - colour and/or text - you supply the whole of the 'decoration' to be added to the field. Any such 'decoration' you supply is displayed in the same place as field-level highlight tiles would be: adjacent to the field values themselves. You need to reimplement the hookHighlighting_GetForField hook.
This is very similar to record-level 'other decorations' highlighting; the only difference is where the decoration is placed - adjacent to the field itself. In pedigrees and other plate-based displays, it looks very similar. But in search results screens the decoration is placed to the right of the field value column, not in a separate column to the left.
The example below shows the addition of a custom decoration highlight based on the date of birth field ('A_DOB'). It tests the birth year, and if it is in the 1970's, adds a 'bone' gif image to the field value; again, hardly a real world example but it shows the basics of getting the field data and using it to generate a highlight.
Show/Hide Sample Code
# Hook function to determine highlighting for a specific
# field within a record - storing the required highlighting
# decorations in a supplied map.
#
# Arg 1 - table suffix
# Arg 2 - reference to map holding decoded highlight definition
# Arg 3 - context
# Arg 4 - reference to map into which highlight effects are to be stored
# Arg 5 - reference to map of field values
# Arg 6 - primary key
# Arg 7 - field name prefix
# Arg 8 - full field name
# Arg 9 - reference to map into which highlighting state can be stored
# for the current panel
# OPTIONAL
# Arg 10 - reference to map for future additional arguments; possibly undefined
sub hookHighlighting_GetForField {
my ($strTableSuffix, $rmHighlightingDef, $strContext, $rmEffects,
$rmFieldValues, $nPrimaryKey, $strFldPrefix, $strFullFldName,
$rmState, $rmArgsEx) = @_;
# You probably dont want to interfere with the correct working of
# pedserve's internally defined highlighting methods. So what you
# should do is make your highlighting definition identifiable
# - by including terms that you can test for here. Then you can
# defer to the default implementation when necessary.
my $fUseStdImpl = 1;
# Example that checks for the term 'myhighlighting=yes'
# in the highlighting definition, and if present handles it here.
# To use this, you would have to define a highlighting during the
# script startup with a call to &pdsSetHighlightingDef() e.g.
# &pdsSetHighlightingDef('A_myhighlighting',
# 'label=Highlight DOB;myhighlighting=yes;');
# Note also the check against $strTableSuffix to ensure this is only
# used with animal records, and the check that this is not a
# pedserve-private definition:
if (!defined($$rmHighlightingDef{'pdsprivate'}) &&
$strTableSuffix eq 'A' &&
defined($$rmHighlightingDef{'myhighlighting'}) &&
$$rmHighlightingDef{'myhighlighting'} eq 'yes') {
# Dont defer to standard implementation below:
$fUseStdImpl = 0;
# This demonstrates field-level highlighting by adding
# an 'other decoration' to the rendered output for a record.
# Our 'decoration' is 'bone icon'
if ($strFullFldName eq $strFldPrefix.'A_DOB') {
# Extract the value of the date of birth field from the
# field results map:
my $date = $$rmFieldValues{$nPrimaryKey.':'.$strFldPrefix.'A_DOB'};
# If the DOB is valid and in the 1970's:
if (defined($date) && $date =~ m/^197.*/) {
# ... then we will decorate the
# field with a gif image:
$$rmEffects{'otherdecorations'} =
$::g_q->img({'-src' =>
&pdsMakeStaticFileURL('bone.gif')});
}
}
}
# If the above code has not handled this highlighting definition
# itself, defer to the standard implementation:
if ($fUseStdImpl) {
&pdsHookStdImpl_Highlighting_GetForField(
$strTableSuffix, $rmHighlightingDef, $strContext, $rmEffects,
$rmFieldValues, $nPrimaryKey, $strFldPrefix, $strFullFldName,
$rmState, $rmArgsEx);
}
}
This custom highlighting method uses the date of birth field ('A_DOB'). When Pedserve fetches data from the database, it does not automatically fetch all the fields - it only fetches those it needs. For this reason, when your custom highlighting method is selected, you need to take steps to ensure that Pedserve will pull any fields you need. You do this by reimplementing the hookHighlighting_GetExtraFlds hook:
Show/Hide Sample Code
# Hook function to return extra fields that are required by a given
# highlighting method.
#
# Arg 1 - table suffix
# Arg 2 - reference to map holding decoded highlight definition
# Arg 3 - context
# Arg 4 - field name prefix
# OPTIONAL
# Arg 4 - reference to map for future additional arguments; possibly undefined
sub hookHighlighting_GetExtraFlds {
my ($strTableSuffix, $rmHighlightingDef,
$strContext, $strFldPrefix, $rmArgsEx) = @_;
# You probably dont want to interfere with the correct working
# of pedserve's internally defined highlighting methods.
# So what you should do is make your highlighting definition
# identifiable - by including terms that you can test
# for here. Then you can defer to the default implementation
# when necessary.
my $fUseStdImpl = 1;
my $strReturn = '';
# Trivial example that checks for the term 'myhighlighting=yes'
# in the highlighting definition, and if present returns a specific
# field name. To use this, you would have to define a highlighting
# method during the script startup with a call to
# &pdsSetHighlightingDef() e.g.
# &pdsSetHighlightingDef('A_myhighlighting',
# 'label=Highlight DOB;myhighlighting=yes;');
# Note also the check against $strTableSuffix to ensure this is only
# used with animal records, and
# the check that this is not a pedserve-private definition:
if (!defined($$rmHighlightingDef{'pdsprivate'}) &&
$strTableSuffix eq 'A' &&
defined($$rmHighlightingDef{'myhighlighting'}) &&
$$rmHighlightingDef{'myhighlighting'} eq 'yes') {
# Dont defer to standard implementation below:
$fUseStdImpl = 0;
# Set the fields to return:
# (this example will use the date of birth field to apply specific
# highlights for given dates etc)
$strReturn = $strFldPrefix.'A_DOB';
}
# If the above code has not handled this highlighting definition itself,
# defer to the standard implementation:
if ($fUseStdImpl) {
$strReturn = &pdsHookStdImpl_Highlighting_GetExtraFlds($strTableSuffix,
$rmHighlightingDef, $strContext, $strFldPrefix, $rmArgsEx);
}
return $strReturn;
}
|
|
|

Field Highlighting - Background Highlight - Pedigree

Field Highlighting - Background Highlight - Search Results
|
With the background colouring highlighting method, you supply an inline CSS style to be applied to the whole field. Whatever string you supply is inserted into an HTML tag that encloses the HTML of the field value, using the style attribute.
Typically this is used to apply a visual effect to the background of the tag - applying a background color and/or image tile. However because all that Pedserve does with the text you supply is to place it within a style attribute, you could supply whatever (appropriate) CSS code you want.
The example below sets the background colour depending on the date of birth field ('A_DOB'). It tests the birth year, and if it is in the 1980's, returns a style string of background-color: #e0e000; which results in a yellow background, or if it is in the 1970's, returns a style string of background-color: #e02040; (reddish); again, hardly a real world example but it shows the basics of getting the field data and using it to generate a highlight.
Show/Hide Sample Code
# Hook function to determine highlighting for a specific
# field within a record - storing the required highlighting
# decorations in a supplied map.
#
# Arg 1 - table suffix
# Arg 2 - reference to map holding decoded highlight definition
# Arg 3 - context
# Arg 4 - reference to map into which highlight effects are to be stored
# Arg 5 - reference to map of field values
# Arg 6 - primary key
# Arg 7 - field name prefix
# Arg 8 - full field name
# Arg 9 - reference to map into which highlighting state can be stored
# for the current panel
# OPTIONAL
# Arg 10 - reference to map for future additional arguments; possibly undefined
sub hookHighlighting_GetForField {
my ($strTableSuffix, $rmHighlightingDef, $strContext, $rmEffects,
$rmFieldValues, $nPrimaryKey, $strFldPrefix, $strFullFldName,
$rmState, $rmArgsEx) = @_;
# You probably dont want to interfere with the correct working of
# pedserve's internally defined highlighting methods. So what you
# should do is make your highlighting definition identifiable
# - by including terms that you can test for here. Then you can
# defer to the default implementation when necessary.
my $fUseStdImpl = 1;
# Example that checks for the term 'myhighlighting=yes'
# in the highlighting definition, and if present handles it here.
# To use this, you would have to define a highlighting during the
# script startup with a call to &pdsSetHighlightingDef() e.g.
# &pdsSetHighlightingDef('A_myhighlighting',
# 'label=Highlight DOB;myhighlighting=yes;');
# Note also the check against $strTableSuffix to ensure this is only
# used with animal records, and the check that this is not a
# pedserve-private definition:
if (!defined($$rmHighlightingDef{'pdsprivate'}) &&
$strTableSuffix eq 'A' &&
defined($$rmHighlightingDef{'myhighlighting'}) &&
$$rmHighlightingDef{'myhighlighting'} eq 'yes') {
# Dont defer to standard implementation below:
$fUseStdImpl = 0;
# This demonstrates highlighting by setting the background
# colour for the field.
if ($strFullFldName eq $strFldPrefix.'A_DOB') {
# This is the date of birth field.
# Extract the actual value of the field from the field results map:
my $date = $$rmFieldValues{$nPrimaryKey.':'.$strFldPrefix.'A_DOB'};
# If the DOB is valid and in the 1980's:
if (defined($date) && $date =~ m/^198.*/) {
# Set a CSS style for the field:
$$rmEffects{'inlinestyle_css'} = 'background-color: #e0e000;';
$$rmEffects{'inlinestyle_legend'} =
$::g_q->escapeHTML("Born in the 1980's");
}
# If the DOB is valid and in the 1970's:
if (defined($date) && $date =~ m/^197.*/) {
# Set a CSS style for the field:
$$rmEffects{'inlinestyle_css'} = 'background-color: #e02040;';
$$rmEffects{'inlinestyle_legend'} =
$::g_q->escapeHTML("Born in the 1970's");
}
}
}
# If the above code has not handled this highlighting definition
# itself, defer to the standard implementation:
if ($fUseStdImpl) {
&pdsHookStdImpl_Highlighting_GetForField(
$strTableSuffix, $rmHighlightingDef, $strContext, $rmEffects,
$rmFieldValues, $nPrimaryKey, $strFldPrefix, $strFullFldName,
$rmState, $rmArgsEx);
}
}
This custom highlighting method uses the date of birth field ('A_DOB'). When Pedserve fetches data from the database, it does not automatically fetch all the fields - it only fetches those it needs. For this reason, when your custom highlighting method is selected, you need to take steps to ensure that Pedserve will pull any fields you need. You do this by reimplementing the hookHighlighting_GetExtraFlds hook:
Show/Hide Sample Code
# Hook function to return extra fields that are required by a given
# highlighting method.
#
# Arg 1 - table suffix
# Arg 2 - reference to map holding decoded highlight definition
# Arg 3 - context
# Arg 4 - field name prefix
# OPTIONAL
# Arg 4 - reference to map for future additional arguments; possibly undefined
sub hookHighlighting_GetExtraFlds {
my ($strTableSuffix, $rmHighlightingDef,
$strContext, $strFldPrefix, $rmArgsEx) = @_;
# You probably dont want to interfere with the correct working
# of pedserve's internally defined highlighting methods.
# So what you should do is make your highlighting definition
# identifiable - by including terms that you can test
# for here. Then you can defer to the default implementation
# when necessary.
my $fUseStdImpl = 1;
my $strReturn = '';
# Trivial example that checks for the term 'myhighlighting=yes'
# in the highlighting definition, and if present returns a specific
# field name. To use this, you would have to define a highlighting
# method during the script startup with a call to
# &pdsSetHighlightingDef() e.g.
# &pdsSetHighlightingDef('A_myhighlighting',
# 'label=Highlight DOB;myhighlighting=yes;');
# Note also the check against $strTableSuffix to ensure this is only
# used with animal records, and
# the check that this is not a pedserve-private definition:
if (!defined($$rmHighlightingDef{'pdsprivate'}) &&
$strTableSuffix eq 'A' &&
defined($$rmHighlightingDef{'myhighlighting'}) &&
$$rmHighlightingDef{'myhighlighting'} eq 'yes') {
# Dont defer to standard implementation below:
$fUseStdImpl = 0;
# Set the fields to return:
# (this example will use the date of birth field to apply specific
# highlights for given dates etc)
$strReturn = $strFldPrefix.'A_DOB';
}
# If the above code has not handled this highlighting definition itself,
# defer to the standard implementation:
if ($fUseStdImpl) {
$strReturn = &pdsHookStdImpl_Highlighting_GetExtraFlds($strTableSuffix,
$rmHighlightingDef, $strContext, $strFldPrefix, $rmArgsEx);
}
return $strReturn;
}
|
|
|

Field Highlighting - Text Emphasis - Pedigree

Field Highlighting - Text Emphasis - Search Results
|
With the text emphasis field highlighting method, you return a value that Pedserve uses to apply various text effects to an individual field.
This is very similar to record-level text emphasis highlighting; the only difference is that the emphasis is limited to a specific field, not to the whole record.
For a list of the available text effects, see record-level text emphasis highlighting.
The example below sets a different text emphasis for the date of birth field ('A_DOB'). It causes a larger, bold font to be used.
Show/Hide Sample Code
# Hook function to determine highlighting for a specific
# field within a record - storing the required highlighting
# decorations in a supplied map.
#
# Arg 1 - table suffix
# Arg 2 - reference to map holding decoded highlight definition
# Arg 3 - context
# Arg 4 - reference to map into which highlight effects are to be stored
# Arg 5 - reference to map of field values
# Arg 6 - primary key
# Arg 7 - field name prefix
# Arg 8 - full field name
# Arg 9 - reference to map into which highlighting state can be stored
# for the current panel
# OPTIONAL
# Arg 10 - reference to map for future additional arguments; possibly undefined
sub hookHighlighting_GetForField {
my ($strTableSuffix, $rmHighlightingDef, $strContext, $rmEffects,
$rmFieldValues, $nPrimaryKey, $strFldPrefix, $strFullFldName,
$rmState, $rmArgsEx) = @_;
# You probably dont want to interfere with the correct working of
# pedserve's internally defined highlighting methods. So what you
# should do is make your highlighting definition identifiable
# - by including terms that you can test for here. Then you can
# defer to the default implementation when necessary.
my $fUseStdImpl = 1;
# Example that checks for the term 'myhighlighting=yes'
# in the highlighting definition, and if present handles it here.
# To use this, you would have to define a highlighting during the
# script startup with a call to &pdsSetHighlightingDef() e.g.
# &pdsSetHighlightingDef('A_myhighlighting',
# 'label=Highlight DOB;myhighlighting=yes;');
# Note also the check against $strTableSuffix to ensure this is only
# used with animal records, and the check that this is not a
# pedserve-private definition:
if (!defined($$rmHighlightingDef{'pdsprivate'}) &&
$strTableSuffix eq 'A' &&
defined($$rmHighlightingDef{'myhighlighting'}) &&
$$rmHighlightingDef{'myhighlighting'} eq 'yes') {
# Dont defer to standard implementation below:
$fUseStdImpl = 0;
# This demonstrates highlighting by adding text emphasis
# (bold, etc) for all occurrence a specific field,
# irrespective of the value of that field:
if ($strFullFldName eq $strFldPrefix.'A_DOB') {
$$rmEffects{'emphasis_code'} = $::c_EMPH_BOLD | $::c_EMPH_BIG;
# Set up an entry for the highlighting legend.
# Note that setting this to the empty string will cause it
# to be added to the legend with the field name but nothing else.
$$rmEffects{'emphasis_legend'} = '';
}
}
# If the above code has not handled this highlighting definition
# itself, defer to the standard implementation:
if ($fUseStdImpl) {
&pdsHookStdImpl_Highlighting_GetForField(
$strTableSuffix, $rmHighlightingDef, $strContext, $rmEffects,
$rmFieldValues, $nPrimaryKey, $strFldPrefix, $strFullFldName,
$rmState, $rmArgsEx);
}
}
This custom highlighting method uses the date of birth field ('A_DOB'). When Pedserve fetches data from the database, it does not automatically fetch all the fields - it only fetches those it needs. For this reason, when your custom highlighting method is selected, you need to take steps to ensure that Pedserve will pull any fields you need. You do this by reimplementing the hookHighlighting_GetExtraFlds hook:
Show/Hide Sample Code
# Hook function to return extra fields that are required by a given
# highlighting method.
#
# Arg 1 - table suffix
# Arg 2 - reference to map holding decoded highlight definition
# Arg 3 - context
# Arg 4 - field name prefix
# OPTIONAL
# Arg 4 - reference to map for future additional arguments; possibly undefined
sub hookHighlighting_GetExtraFlds {
my ($strTableSuffix, $rmHighlightingDef,
$strContext, $strFldPrefix, $rmArgsEx) = @_;
# You probably dont want to interfere with the correct working
# of pedserve's internally defined highlighting methods.
# So what you should do is make your highlighting definition
# identifiable - by including terms that you can test
# for here. Then you can defer to the default implementation
# when necessary.
my $fUseStdImpl = 1;
my $strReturn = '';
# Trivial example that checks for the term 'myhighlighting=yes'
# in the highlighting definition, and if present returns a specific
# field name. To use this, you would have to define a highlighting
# method during the script startup with a call to
# &pdsSetHighlightingDef() e.g.
# &pdsSetHighlightingDef('A_myhighlighting',
# 'label=Highlight DOB;myhighlighting=yes;');
# Note also the check against $strTableSuffix to ensure this is only
# used with animal records, and
# the check that this is not a pedserve-private definition:
if (!defined($$rmHighlightingDef{'pdsprivate'}) &&
$strTableSuffix eq 'A' &&
defined($$rmHighlightingDef{'myhighlighting'}) &&
$$rmHighlightingDef{'myhighlighting'} eq 'yes') {
# Dont defer to standard implementation below:
$fUseStdImpl = 0;
# Set the fields to return:
# (this example will use the date of birth field to apply specific
# highlights for given dates etc)
$strReturn = $strFldPrefix.'A_DOB';
}
# If the above code has not handled this highlighting definition itself,
# defer to the standard implementation:
if ($fUseStdImpl) {
$strReturn = &pdsHookStdImpl_Highlighting_GetExtraFlds($strTableSuffix,
$rmHighlightingDef, $strContext, $strFldPrefix, $rmArgsEx);
}
return $strReturn;
}
|
|
|

Field Highlighting - Pre/Post Custom HTML - Pedigree

Field Highlighting - Pre/Post Custom HTML - Search Results
|
With the field-level 'Pre/Post HTML' highlighting method, you supply HTML snippets that Pedserve will use to enclose the HTML of specific field values. Use this as a means to applying any other HTML structure/effects you want.
The example below encloses the HTML for all date of birth field values in a <font> tag. It sets a pre-HTML string of <font face="Arial" color="blue">, and a post-HTML string of </font>. The result is that a different font is always used for this field (irrespective of field value).
Show/Hide Sample Code
# Hook function to determine highlighting for a specific
# field within a record - storing the required highlighting
# decorations in a supplied map.
#
# Arg 1 - table suffix
# Arg 2 - reference to map holding decoded highlight definition
# Arg 3 - context
# Arg 4 - reference to map into which highlight effects are to be stored
# Arg 5 - reference to map of field values
# Arg 6 - primary key
# Arg 7 - field name prefix
# Arg 8 - full field name
# Arg 9 - reference to map into which highlighting state can be stored
# for the current panel
# OPTIONAL
# Arg 10 - reference to map for future additional arguments; possibly undefined
sub hookHighlighting_GetForField {
my ($strTableSuffix, $rmHighlightingDef, $strContext, $rmEffects,
$rmFieldValues, $nPrimaryKey, $strFldPrefix, $strFullFldName,
$rmState, $rmArgsEx) = @_;
# You probably dont want to interfere with the correct working of
# pedserve's internally defined highlighting methods. So what you
# should do is make your highlighting definition identifiable
# - by including terms that you can test for here. Then you can
# defer to the default implementation when necessary.
my $fUseStdImpl = 1;
# Example that checks for the term 'myhighlighting=yes'
# in the highlighting definition, and if present handles it here.
# To use this, you would have to define a highlighting during the
# script startup with a call to &pdsSetHighlightingDef() e.g.
# &pdsSetHighlightingDef('A_myhighlighting',
# 'label=Highlight DOB;myhighlighting=yes;');
# Note also the check against $strTableSuffix to ensure this is only
# used with animal records, and the check that this is not a
# pedserve-private definition:
if (!defined($$rmHighlightingDef{'pdsprivate'}) &&
$strTableSuffix eq 'A' &&
defined($$rmHighlightingDef{'myhighlighting'}) &&
$$rmHighlightingDef{'myhighlighting'} eq 'yes') {
# Dont defer to standard implementation below:
$fUseStdImpl = 0;
# This demonstrates highlighting by setting HTML text that
# is to be inserted before+after all occurrences of a specific field,
# irrespective of the value of that field:
if ($strFullFldName eq $strFldPrefix.'A_DOB') {
# Use the font tag to change the font face to Arial, blue:
$$rmEffects{'customhtml_pre'} = '<font face="Arial" color="blue">';
$$rmEffects{'customhtml_post'} = '</font>';
# Set up an entry for the highlighting legend.
# Note that setting this to the empty string will cause it
# to be added to the legend with the field name but nothing else.
$$rmEffects{'customhtml_legend'} = '';
}
}
# If the above code has not handled this highlighting definition
# itself, defer to the standard implementation:
if ($fUseStdImpl) {
&pdsHookStdImpl_Highlighting_GetForField(
$strTableSuffix, $rmHighlightingDef, $strContext, $rmEffects,
$rmFieldValues, $nPrimaryKey, $strFldPrefix, $strFullFldName,
$rmState, $rmArgsEx);
}
}
This custom highlighting method uses the date of birth field ('A_DOB'). When Pedserve fetches data from the database, it does not automatically fetch all the fields - it only fetches those it needs. For this reason, when your custom highlighting method is selected, you need to take steps to ensure that Pedserve will pull any fields you need. You do this by reimplementing the hookHighlighting_GetExtraFlds hook:
Show/Hide Sample Code
# Hook function to return extra fields that are required by a given
# highlighting method.
#
# Arg 1 - table suffix
# Arg 2 - reference to map holding decoded highlight definition
# Arg 3 - context
# Arg 4 - field name prefix
# OPTIONAL
# Arg 4 - reference to map for future additional arguments; possibly undefined
sub hookHighlighting_GetExtraFlds {
my ($strTableSuffix, $rmHighlightingDef,
$strContext, $strFldPrefix, $rmArgsEx) = @_;
# You probably dont want to interfere with the correct working
# of pedserve's internally defined highlighting methods.
# So what you should do is make your highlighting definition
# identifiable - by including terms that you can test
# for here. Then you can defer to the default implementation
# when necessary.
my $fUseStdImpl = 1;
my $strReturn = '';
# Trivial example that checks for the term 'myhighlighting=yes'
# in the highlighting definition, and if present returns a specific
# field name. To use this, you would have to define a highlighting
# method during the script startup with a call to
# &pdsSetHighlightingDef() e.g.
# &pdsSetHighlightingDef('A_myhighlighting',
# 'label=Highlight DOB;myhighlighting=yes;');
# Note also the check against $strTableSuffix to ensure this is only
# used with animal records, and
# the check that this is not a pedserve-private definition:
if (!defined($$rmHighlightingDef{'pdsprivate'}) &&
$strTableSuffix eq 'A' &&
defined($$rmHighlightingDef{'myhighlighting'}) &&
$$rmHighlightingDef{'myhighlighting'} eq 'yes') {
# Dont defer to standard implementation below:
$fUseStdImpl = 0;
# Set the fields to return:
# (this example will use the date of birth field to apply specific
# highlights for given dates etc)
$strReturn = $strFldPrefix.'A_DOB';
}
# If the above code has not handled this highlighting definition itself,
# defer to the standard implementation:
if ($fUseStdImpl) {
$strReturn = &pdsHookStdImpl_Highlighting_GetExtraFlds($strTableSuffix,
$rmHighlightingDef, $strContext, $strFldPrefix, $rmArgsEx);
}
return $strReturn;
}
|