When WebCenter Interaction 10gR3 was released, it was a complete train wreck for documents in the Knowledge Directory – the content headers were wrong, docs wouldn’t download in Internet Explorer due to the comical back-asswards Javascript file open mechanism, and links couldn’t be copied or viewed because the anchor tags were malformed.
In our last post in this painful series, I shared some code that will resolve the ALUI / WCI Knowledge Directory links so that users can right-click and copy the links, and the files open as expected when clicked.
Since then, I’ve found that when an admin is in EDIT mode in the Knowledge Directory, the link calamity continues, and a completely different and incomprehensible linking mechanism is used. So for your reading pleasure today, I’ll update that post to handle edit mode as well as browse mode. Again, just add the following HTML to the footer used in your Knowledge Directory (depending on Experience Definition, there may be more than one):
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<pcs:value expr="text"></pcs:value>
<pt:common.transformer pt:fixurl="off" xmlns:pt='http://www.plumtree.com/xmlschemas/ptui/'/>
<script>
try
{
// KD BROWSE Mode
// <a href="#" onclick="var currentWin = PTCommonOpener.openInNewWindow ('', 'Opener_18_1214986', 800, 600, true); currentWin.location= 'http://portal.integryst.com/portal/server.pt /document/1214936/DocName'; return false;">DocName</a>
if (document.title=="Directory")
{
// get all links
var anchors = document.links;
for (x=0; x<anchors.length; x++) {
// get only those with an onclick event
onclickJS = anchors[x].onclick;
if (onclickJS != null)
{
onclickJS = "" + onclickJS;
var locCommonOpener = onclickJS.indexOf("PTCommonOpener.openInNewWindow");
var locpos = onclickJS.indexOf("currentWin.location");
// only process links that have the broken PTCommonOpener.openInNewWindow
if ((locpos>=0) &amp;&amp; (locCommonOpener>=0))
{
// extract the URL from the broken onclick function
var url = onclickJS.substr(locpos);
var locstart = url.indexOf("'");
if (locstart>=0)
{
url = url.substr(locstart+1);
var locend = url.indexOf("'");
if (locend>=0)
{
// update the URL by clearing the onclick and setting the URL to open in a new window
url = url.substring(0,locend);
anchors[x].href=url;
anchors[x].target="_new";
anchors[x].onclick=null;
}
}
}
}
}
}
// KD Edit Mode
// <a href="#" onclick="var currentWin = PTCommonOpener.openInNewWindow ('', 'Opener_18_1214986', 800, 600, true); currentWin.location = PTCommonOpener.getOpenerURLOpenObjID (18, 1214926, '', 2); return false;"> DocName </a>
if (document.title=="Edit Directory")
{
// get all links
var anchors = document.links;
for (x=0; x<anchors.length; x++) {
// get only those with an onclick event
onclickJS = anchors[x].onclick;
if (onclickJS != null)
{
onclickJS = "" + onclickJS;
var locCommonOpener = onclickJS.indexOf("PTCommonOpener.openInNewWindow");
var locpos = onclickJS.indexOf("currentWin.location");
// only process links that have the broken PTCommonOpener.openInNewWindow
if ((locpos>=0) &amp;&amp; (locCommonOpener>=0))
{
// extract the URL from the broken onclick function
var url = onclickJS.substr(locpos);
var locstart = url.indexOf("=");
if (locstart>=0)
{
url = url.substr(locstart+1);
var locend = url.indexOf(";");
if (locend>=0)
{
// update the URL by clearing the onclick and setting the URL to open in a new window
url = url.substring(0,locend+1);
anchors[x].href=eval(url);
anchors[x].target="_new";
anchors[x].onclick=null;
}
}
}
}
}
}
}
catch (err)
{
// ignore errors
}
</script>
On a completely unrelated note, thanks to my wonderful numbering scheme of these posts, I can now count to four in French…
Tags: Bug, Code Samples, Experience Definition, hack, javascript, Knowledge Directory


