Bug 575 - [chameleon] Keymap widget cannot use a URL for file location
: [chameleon] Keymap widget cannot use a URL for file location
Status: CLOSED FIXED
: Chameleon
Widget
: 1.99
: PC Windows 2000
: P1 major
: 1.99 beta 3
Assigned To:
:
:
:
:
:
  Show dependency treegraph
 
Reported: 2004-07-21 15:19 by
Modified: 2004-10-26 12:39 (History)


Attachments


Note

You need to log in before you can comment on or make changes to this bug.


Description From 2004-07-21 15:19:10
Especially when using the service instance we need to be able to specify an
image in the keymap widget as a URL since the applicaiton developer might not
have access the to applcation server.

Right now in version cwc2-1.99beta-20040709 this cannot be done. Using a URL
results in a broken image. 

This will need to be changed in order to complete the GoMOOS FGDC project
applicaitons, therefore I"m marking this as P1.
------- Comment #1 From 2004-07-22 14:54:48 -------
Changing target to 1.99 beta 3. (This doesn't mean it shouldn't be done a.s.a.p 
for GoMOOS - only that it isn't critical to the general Beta 2 release.)
------- Comment #2 From 2004-08-10 15:36:46 -------
Changing Version to 1.99 (2.0 not being worked on yet).
------- Comment #3 From 2004-09-30 16:48:34 -------
Taking this one since it's a P1.
------- Comment #4 From 2004-09-30 16:50:08 -------
Starting working on this.
I will propose my patch here before commiting anything since we are playing with
URL and so with security.
------- Comment #5 From 2004-10-01 10:38:45 -------
I noticed 2 problems while working on this. But I want to make sure with Paul
that they were not intentional before commiting anything. My change would be in
the core, so I want to make sure they are ok.

1- The fileSystemToURL() function did not check for the TmpImgPath directory.
2- There's no way of making a non-web-visible file web-visible.

To fix that I added in this function the functionality to copy files to the
TmpWebPath directory and to get file from the TmpIngPath.

Should I've done a new function for this purpose? Or is it ok to put them there?

Look:
function fileSystemToURL( $szFileSystemPath, $bMakeWebVisible=false )
{
    $szFileSystemPath = str_replace( '\\', '/', $szFileSystemPath );
    $szFileSystemPath = ereg_replace ("/+", "/", $szFileSystemPath);
    //echo "filesystem path: $szFileSystemPath<BR>";

    $szAppPath = str_replace( '\\', '/', realpath($_SESSION['gszAppPath']) );
    $szAppPath = ereg_replace ("/+", "/", $szAppPath);
    //echo "app path: $szAppPath<BR>";

    if (strncmp( $szFileSystemPath, $szAppPath, strlen($szAppPath) ) == 0)
        return $_SESSION['gszAppWebPath'].'/'.substr( $szFileSystemPath,
strlen($szAppPath));

    $szCorePath = str_replace( '\\', '/', realpath($_SESSION['gszCorePath']) );
    $szCorePath = ereg_replace ("/+", "/", $szCorePath);
    if (strncmp( $szFileSystemPath, $szCorePath, strlen($szCorePath) ) == 0)
    return
$_SESSION['gszCoreWebPath'].'/'.substr($szFileSystemPath,strlen($szCorePath));

    $szTmpImgPath = str_replace( '\\', '/', 
                                 realpath($_SESSION['gszTmpImgPath']) );
    $szTmpImgPath = ereg_replace ("/+", "/", $szTmpImgPath);
    if (strncmp( $szFileSystemPath, $szTmpImgPath, strlen($szTmpImgPath) ) == 0)
        return
$_SESSION['gszTmpWebPath'].'/'.substr($szFileSystemPath,strlen($szTmpImgPath));

    if($bMakeWebVisible == true && is_file($szFileSystemPath))
    {
        $szDestFileName = $szTmpImgPath.'/'.
            substr($szFileSystemPath, strrpos($szFileSystemPath, '/'));
        copy($szFileSystemPath, $szDestFileName);
        return
$_SESSION['gszTmpWebPath'].'/'.substr($szDestFileName,strlen($szTmpImgPath)+1);
    }

    return $szFileSystemPath;
}
------- Comment #6 From 2004-10-01 17:42:03 -------
do these changes fix the problem?  Can you describe the actual problem in more
detail and how this fixes it?  Other than that, if its fixed, I'm happy :)
------- Comment #7 From 2004-10-12 14:39:09 -------
This fix the problem by downloading the image and putting it in the session
folder (this was already done). What my changes do is to copy this image in the
gszTmpWebPath and return this path. So now the image is on the machine and
available from the web.
------- Comment #8 From 2004-10-26 08:42:04 -------
even though the keymap is working how can we verifiy that this was a successful
fix. :) Julie? Paul?
------- Comment #9 From 2004-10-26 08:56:25 -------
The original problem was that using a URL with the keymap widget did not work. 
I would suggest that you can verify by modifying a cwc2 template and changing
the keymap widget to use a remote image as its source and see if it works :)
------- Comment #10 From 2004-10-26 11:29:11 -------
Maybe I should read the bug. doh! I have been verify is getting to me. ;)

was able to get keymap in application using a URL:
 <cwc2 type="KeyMapDHTML"
image="http://nemesis/chameleon/samples/images/keymap.png" />

verified on windows beta3 20041022

set to verified.
------- Comment #11 From 2004-10-26 12:39:07 -------
Verified on Fedora Core 2 following comments #9 and #10.