create or replace package body odwahelp
is
/*****************************************************************************************
Purpose Provide access to the On-Line help system of ODWA6i
Usage
Remarks
Revision history
When Who Construct
Revision What
------------------------------------------------------------------------------------------
$REVISION_HISTORY$
06-Dec-2002 Kannan Parthasarathy
- B2695653 Fixed.
14-Nov-2002 Kannan Parthasarathy
- Fixed OAC p1 violations.
06-oct-2002 Kannan Parthasarathy
- Bug 2610181: Changed TITLE of the help page.
24-sep-2002 Kannan Parthasarathy
- Changes made to accommodate new logo.
21-feb-2001 Lucas Jellema
1.6 - issue 195 Also See.. is sorted in wrong order [odwa project/195%]
30-jan-2001 Lucas Jellema
1.5 - show static documents
- function help_url: do not return URL+gif if help item does not exist (ISSUE 151)
- procedure help_bar_frame: only show create/edit button when odwa_pref edit_help_allowed =Y (ISSUE= 150)
-
29-jan-2001 Lucas Jellema
1.4 - remove odwa_help_tree
25-jan-2001 Lucas Jellema
1.3 - use preference edit_help_allowed to determine whether the edit/create help item icons should be displayed
15-jan-2001 Peter Ebell
1.2 - Added Self Service header
12-jan-2001 Lucas Jellema
1.1 Add functionality to Edit and Create Help Items
22-dec-2000 Lucas Jellema
1.0 Initial creation.
*****************************************************************************************/
--
-- private constants
--
REVISION_LABEL constant varchar2(30) := '$x.y::1.6 $';
PACKAGE_NAME constant varchar2(30) := 'ODWAHELP';
-- this variable holds the value of the (Virtual) Document directory, derived
-- from the doc_path odwa_preference
g_odwa_doc_path varchar2(2000);
g_allow_help_edit boolean;
type t_htt_table
is table of varchar2(4000)
index by binary_integer
;
g_htt_table t_htt_table;
cursor c_him ( b_him_id in number)
is
select him.id
, him.document
, him.description
, him.keywords
from odwa_help_items him
where him.id = b_him_id
;
cursor c_hnd
( b_hnd_id in number
) is
select hnd.seq_in_parent
, hnd.tree_level
, hnd.display_label
, hnd.him_id
, hnd.parent_node
, hnd.id
from odwa_help_nodes hnd
where hnd.id = b_hnd_id
;
cursor c_hnd_for_him
( b_him_id in number
) is
select hnd.seq_in_parent
, hnd.tree_level
, hnd.display_label
, hnd.him_id
, hnd.parent_node
, hnd.id
from odwa_help_nodes hnd
where hnd.him_id = b_him_id
;
r_hnd c_hnd%rowtype;
cursor c_hnd_tree
( b_parent_node in number default 0
)
is
select hnd.seq_in_parent
, hnd.tree_level
, hnd.display_label
, hnd.him_id
, hnd.parent_node
, hnd.id
, hnd.rowid hnd_rowid
from odwa_help_nodes hnd
start
with hnd.parent_node = b_parent_node
connect
by prior id = parent_node
;
cursor c_hnd_chld
( b_parent_hnd_id in number
) is
select hnd.seq_in_parent
, hnd.tree_level
, hnd.display_label
, hnd.him_id
, hnd.parent_node
, hnd.rowid hnd_rowid
, hnd.id
from odwa_help_nodes hnd
where hnd.parent_node = b_parent_hnd_id
order
by hnd.seq_in_parent
;
r_him c_him%rowtype;
-- this procedure will fetch the row from ODWA_HELP_ITEMS for the indicated
-- help item and store it in r_him
procedure cache_him
( p_him_id in number
) is
begin
open c_him( b_him_id => p_him_id);
fetch c_him
into r_him;
close c_him;
end; -- cache_him
-- this procedure will fetch the row from ODWA_HELP_NODES for the indicated
-- help node and store it in r_hnd
procedure cache_hnd
( p_hnd_id in number
) is
begin
open c_hnd( b_hnd_id => p_hnd_id);
fetch c_hnd
into r_hnd;
close c_hnd;
end; -- cache_him
-- this procedure will fetch the row from ODWA_HELP_NODES for the indicated
-- help node and store it in r_hnd
procedure cache_hnd_for_him
( p_him_id in number
) is
begin
open c_hnd_for_him( b_him_id => p_him_id);
fetch c_hnd_for_him
into r_hnd;
close c_hnd_for_him;
end; -- cache_him
-- this procedures retrieves and caches in g_htt_table
-- the help text blocks for help item b_him_id
procedure cache_htt
( p_him_id in number
) is
cursor c_htt( b_him_id in number)
is
select htt.txt
from odwa_help_text htt
where htt.him_id = b_him_id
order
by htt.seq
;
begin
open c_htt( b_him_id => p_him_id);
FETCH c_htt
BULK COLLECT
INTO g_htt_table;
close c_htt;
end;
-- this procedure writes a JavaScript function into the HeadSection of an HTML document
-- the function, showHelp( id), can be called to bring up a window with help on a specific topic
-- calls to this function can be retrieved from the function odwahelp.help_url
procedure js_invoke_help
is
begin
htp.p('
'
);
end; -- js_invoke_help
-- this function returns the JavaScript call to be made to invoke the help for the indicated item
function help_call
( p_him_id in number
) return varchar2
is
begin
return 'showHelp('''||to_char(p_him_id)||''')';
end; --help_url
-- this function will return a url to show the help for the indicated item
-- note that this url should only be used in a document that contains the showHelp function
function help_url
( p_him_id in number
, p_icon in boolean default true
, p_text in varchar2 default null
, p_alt_text in varchar2 default null
, p_top in boolean default false -- is the JavaScript function to be located in the Top (Window) frame (instead of the current frame)
) return varchar2
is
begin
-- $% x.y $ if help item does not exist, then return '' else return URL
cache_him( p_him_id => p_him_id);
if r_him.id is null
then
return '';
else
return ''
||cdwpbase.ifThenElse
( p_icon
, cdwp.add_images
( '{help.gif}'
, p_attributes => cdwpbase.ifThenElse
( p_alt_text is not null
, 'ALT="'||p_alt_text||'"'
)
)
)
||p_text
||''
;
end if; -- r_him.id is null
end; --help_url
-- procedure display the result of a Search in the helpItemFrame as initiated from the Search item
-- in the helpBarFrame
procedure searchHelp
( searchString in varchar2
, p_session_id in number
) is
l_search_string varchar2(200):= lower(ltrim(rtrim(searchString)));
cursor c_him
( b_searchString in varchar2)
is
select him.id
, him.document
, him.description
, him.keywords
from odwa_help_items him
where instr(lower(him.description), b_searchString) > 0
or instr(lower(him.keywords), b_searchString) > 0
order
by him.description
;
-- this function may help perform a more refined/sophisticated search
function inSearch
( p_description in varchar2
, p_keywords in varchar2
) return boolean
is
begin
return true;
end; --inSearch
begin
-- create session when necessary, refresh session cache, set workarea context
-- from here on reference to odwactxt.get_... functions for any context value
odwactxt.update_context
( p_package_name => PACKAGE_NAME
, p_procedure_name=> 'helpBarFrame'
, p_session_id => p_session_id
);
htp.htmlOpen;
htp.headOpen;
cdwp.write_about(package_name, revision_label);
cdwp.include_report_styles;
htp.headClose;
htp.bodyopen
( cattributes => 'BGCOLOR="#FFFFFF"'
);
cdwp.p
( Rob_msg.GetMsg(Rob_msg.DSP240_ODWAHELP_SRCHR,'','','','')
||searchString
, p_style => 'partitle'
);
htp.nl;
for r_him in c_him( b_searchString => l_search_String) loop
if inSearch( r_him.description, r_him.keywords)
then
/* open new window */
htp.p
( ''
||r_him.description
||' '
);
end if; -- inSearch
end loop; -- r_him
htp.bodyClose;
htp.htmlClose;
end; -- searchHelp
-- this procedure will write a piece of HTML that displays a search item that, when pressed, will result
-- in a search being executed in the On Line Help for the search string
procedure writeSearchHelp
is
begin
htp.p( '
');
end; -- writeSearchHelp
procedure helpBarFrame
( p_session_id in number default null
, p_him_id in number -- the help item id (refers to table ODWA_HELP_ITEMS.id)
, p_hnd_id in number default null -- the node id ODWA_HELP_NODES table
) is
l_menu_bar varchar2(500);
begin
-- create session when necessary, refresh session cache, set workarea context
-- from here on reference to odwactxt.get_... functions for any context value
odwactxt.update_context
( p_package_name => PACKAGE_NAME
, p_procedure_name=> 'helpBarFrame'
, p_session_id => p_session_id
);
if p_hnd_id is null
then
cache_hnd_for_him
( p_him_id => p_him_id
);
else
cache_hnd( p_hnd_id);
end if;
cache_him( p_him_id);
l_menu_bar:=cdwp.add_images( p_text => '{ft-left.gif}');
l_menu_bar:= l_menu_bar
||htf.anchor2
( ctext=> cdwp.add_images
( '{editprivsgr.gif}'
, p_attributes => 'ALT="Edit Help Item"'
)
, curl => 'odwahelp.editHelpItem?'
||'p_session_id='||to_char(p_session_id)
||chr(38)||'p_him_id='||to_char(p_him_id)
||chr(38)||'p_hnd_id='||to_char(r_hnd.id)
, ctarget => 'helpFrame'
)
||htf.anchor2
( ctext=> cdwp.add_images
( '{additiongr.gif}'
, p_attributes => 'ALT="Create New Help Item"'
)
, curl => 'odwahelp.editHelpItem?'
||'p_session_id='||to_char(p_session_id)
, ctarget => 'helpFrame'
);
l_menu_bar:= l_menu_bar
||cdwp.add_images
( p_text => '{ft-right.gif}'
, p_attributes=> ' Qwidth="25" '
)
;
htp.htmlOpen;
htp.headOpen;
cdwp.write_about(package_name, revision_label);
cdwp.include_report_styles;
htp.headClose;
htp.bodyopen
( cattributes => 'BGCOLOR="#FFFFFF"'
);
if g_allow_help_edit
then
htp.tableopen( cattributes => 'BORDER="0" align="RIGHT"'); -- 1.4 bgcolor="88DDF9"
cdwp.tableRowOpen;
htp.tabledata
( cvalue=> l_menu_bar
, calign => 'right'
, cattributes => 'Zwidth="400" ABGCOLOR="#cccccc"'
);
cdwp.tableRowClose;
cdwp.tableClose;
end if; -- g_allow_help_edit = true
writeSearchHelp;
cdwp.p
( nvl( nvl( r_him.description, r_hnd.display_label) , Rob_msg.GetMsg(Rob_msg.DSP241_ODWAHELP_TITLE,'','','',''))
, p_style => 'partitle'
);
htp.bodyClose;
htp.htmlClose;
end; -- helpBarFrame
-- this procedure will write a framework HTML document
-- fleshed out with the text stored for the current Help Item p_him_id
-- in the table ODWA_HELP_TET.
procedure helpItemFrame
( p_session_id in number default null
, p_him_id in number -- the help item id (refers to table ODWA_HELP_ITEMS.id)
, p_hnd_id in number default null -- the node id ODWA_HELP_NODES table
) is
l_first boolean;
l_recursive_check number(2):=1;
cursor c_htt
( b_him_id in number
) is
select htt.txt
from odwa_help_text htt
where htt.him_id = b_him_id
order
by htt.seq
;
procedure also_see_children
( p_level in number
, p_hnd_id in number
) is
cursor c_hnd_chld
( b_parent_hnd_id in number
) is
select hnd.seq_in_parent
, hnd.tree_level
, hnd.display_label
, hnd.him_id
, hnd.parent_node
, hnd.rowid hnd_rowid
, hnd.id
from odwa_help_nodes hnd
where hnd.parent_node = b_parent_hnd_id
order
by hnd.seq_in_parent
;
begin
l_recursive_check:= l_recursive_check+1;
for r_hnd_chld in c_hnd_chld( b_parent_hnd_id => p_hnd_id) loop
if l_first
then
l_first:= false;
htp.p('
');
end if; -- l_first
htp.p
( cdwpbase.nbsp( p_level * 5)
||''
||r_hnd_chld.display_label
||''
||' '
);
also_see_children
( p_level + 1
, r_hnd_chld.id
);
end loop; -- r_hnd_chld
end; -- also_see_children
begin
-- create session when necessary, refresh session cache, set workarea context
-- from here on reference to odwactxt.get_... functions for any context value
odwactxt.update_context
( p_package_name => PACKAGE_NAME
, p_procedure_name=> 'helpItemFrame'
);
cache_him( p_him_id);
if p_hnd_id is null
then
cache_hnd_for_him
( p_him_id => p_him_id
);
else
cache_hnd( p_hnd_id);
end if;
htp.htmlOpen;
htp.headOpen;
cdwp.write_about(package_name, revision_label);
cdwp.include_report_styles;
htp.headClose;
htp.bodyopen
( cattributes => 'BGCOLOR="#FFFFFF"'
);
for r_htt in c_htt( b_him_id => p_him_id) loop
htp.p
( cdwp_txt.add_ent_anchors
( ''
, r_htt.txt
, ''
)
);
end loop; -- r_htt
l_first:= true;
if p_him_id is not null
then
for r_hnd_for_him in c_hnd_for_him( b_him_id => p_him_id) loop
-- now also show the sub-items according to the tree definition
also_see_children
( p_level => 1
, p_hnd_id => r_hnd_for_him.id
);
end loop; -- r_hnd_for_him
else
also_see_children
( p_level => 1
, p_hnd_id => p_hnd_id
);
end if; -- p_him_id is not null
htp.bodyClose;
htp.htmlClose;
end; -- helpItemFrame
-- this procedure writes the JavaScript function that is necessary to be able to invoke
-- a viewlet from within the current document
-- IF this procedure is called between htp.headOpen and htp.headClose, Viewlets can be linked
-- to in the HTML page using the following URL:
-- href="javascript:parent.showViewlet('')"
procedure js_invoke_viewlet
is
begin
htp.p('
');
end; -- js_invoke_viewlet
-- main procedure
-- -------------------------------
-- | helpBarFrame |
-- | |
-- | |
-- |-----------------------------|
-- | |
-- | helpItemFrame |
-- | |
-- -------------------------------
--
--
procedure show_help_item
( p_session_id in number default null
, p_him_id in number -- the help item id (refers to table ODWA_HELP_ITEMS.id)
, p_hnd_id in number default null -- the node id ODWA_HELP_NODES table
) is
l_menu_bar varchar2(500);
begin
-- create session when necessary, refresh session cache, set workarea context
-- from here on reference to odwactxt.get_... functions for any context value
odwactxt.update_context
( p_package_name => PACKAGE_NAME
, p_procedure_name=> 'show_help_item'
);
cache_him( p_him_id);
htp.htmlOpen;
htp.headOpen;
cdwp.write_about(package_name, revision_label);
cdwp.include_report_styles;
htp.title
( Rob_msg.GetMsg(Rob_msg.DSP241_ODWAHELP_TITLE,'','','','')
||r_him.description
);
js_invoke_viewlet;
js_invoke_help;
htp.headClose;
htp.framesetopen
( crows => '15%,85%'
, cattributes => 'BORDER="0" TITLE="'
||Rob_msg.Getmsg(rob_msg.DSP104_CDWP_HELP,'','','','')||'" LONGDESC=odwahelp.rightSide?p_session_id=&p_him_id=150'
);
htp.frame
( csrc => 'odwahelp.helpBarFrame?p_session_id='
||to_char(odwactxt.get_session_id)
||chr(38)||'p_him_id='||nvl(to_char(p_him_id), cdwpbase.ifThenElse( p_hnd_id is null, '1000'))
||chr(38)||'p_hnd_id='||to_char(p_hnd_id)
, cname=> 'helpBarFrame '
, cattributes=> 'LONGDESC="" TITLE="'
||Rob_msg.Getmsg(rob_msg.ACC009_BROW_FRAME,'','','','')||'"'
);
-- if the help item refers to a static document, the helpItemFrame
-- should be linked to that document
-- if the help item is contained in the ODWA_HELP_TEXT table, the
-- procedure helpItemFrame is invoked
if r_him.document is null
then
htp.frame
( csrc => 'odwahelp.helpItemFrame?p_session_id='
||to_char(odwactxt.get_session_id)
||chr(38)||'p_him_id='||nvl(to_char(p_him_id), cdwpbase.ifThenElse( p_hnd_id is null, '1000'))
||chr(38)||'p_hnd_id='||to_char(p_hnd_id)
, cname=> 'helpItemFrame'
, cattributes=>'LONGDESC="" TITLE="'
||Rob_msg.Getmsg(rob_msg.DSP104_CDWP_HELP,'','','','')||'"'
);
else
htp.frame
( csrc => g_odwa_doc_path||r_him.document -- 1.5
, cname=> 'helpItemFrame'
, cattributes=>'LONGDESC="" TITLE="'
||Rob_msg.Getmsg(rob_msg.DSP104_CDWP_HELP,'','','','')||'"'
);
end if; -- r_him.document is null
htp.framesetclose;
htp.bodyopen
( cattributes => 'BGCOLOR="#FFFFFF"'
);
htp.bodyClose;
htp.htmlClose;
end; -- show_help_item
-- initialize text areas
procedure js_init
is
begin
htp.p
('
'
);
end; -- js_init
procedure js_addHelpReference
is
begin
htp.p
(' ' ||
' '
);
end; -- js_addHelpReference
-- this procedure displays an existing or new help item in editable form items
procedure editHelpItem
( p_session_id in number
, p_him_id in number default null
, p_hnd_id in number default null -- the node id ODWA_HELP_NODES table
) is
l_txt1 varchar2(4000);
l_txt2 varchar2(4000);
l_txt3 varchar2(4000);
begin
odwactxt.update_context
( p_session_id => p_session_id
, p_package_name => PACKAGE_NAME
, p_procedure_name=> 'editHelpItem'
);
cache_him( p_him_id);
cache_htt( p_him_id);
cache_hnd( p_hnd_id);
htp.htmlOpen;
htp.headOpen;
cdwp.write_about(package_name, revision_label);
cdwp.include_report_styles;
js_invoke_viewlet;
js_invoke_help;
js_init;
js_addHelpReference;
htp.headClose;
htp.bodyopen
( cattributes => 'BGCOLOR="#FFFFFF" onLoad="init()"'
);
htp.formopen
( curl => 'odwahelp.saveHelpItem'
, cmethod => 'POST'
, cattributes => 'NAME="himForm"'
);
htp.formhidden(cname => 'p_session_id', cvalue => to_char(odwactxt.get_session_id));
htp.formhidden(cname => 'him_id', cvalue => to_char(p_him_id));
htp.formhidden(cname => 'p_hnd_id', cvalue => to_char(p_hnd_id));
htp.p( '');
htp.p( '');
htp.p( '');
htp.tableopen;
cdwp.tablerowopen;
cdwp.tabledataheading('#'||to_char(p_him_id));
cdwp.tabledatavalue( htf.formtext(cname => 'p_description' ,csize => 40 ,cmaxlength => 200 ,cvalue => nvl( r_him.description, r_hnd.display_label)));
cdwp.tablerowclose;
cdwp.tablerowopen;
cdwp.tabledataheading(p_heading => Rob_msg.GetMsg(Rob_msg.DSP242_ODWAHELP_STDOC,'','','',''));
cdwp.tabledatavalue( htf.formtext(cname => 'p_document' ,csize => 30 ,cmaxlength => 200 ,cvalue => r_him.document));
cdwp.tablerowclose;
cdwp.tablerowopen;
cdwp.tabledataheading(Rob_msg.GetMsg(Rob_msg.CAP120_ODWAHELP_KW,'','','',''));
cdwp.tabledatavalue( htf.formtext(cname => 'p_keywords' ,csize => 50 ,cmaxlength => 500 ,cvalue => r_him.keywords));
cdwp.tablerowclose;
cdwp.tablerowopen;
cdwp.tabledataheading(Rob_msg.GetMsg(Rob_msg.DSP243_ODWAHEMP_PNODE,'','','',''));
htp.p('