link to a file on a local HD or mapped NW dev

2007-03-28
2013-05-28
  • Knut Krüger

    Knut Krüger - 2007-03-28

    Is there a possibility to set the related pointer to a local file or a mapped network device?

    Regards Knut

     
    • Richard Karnesky

      The 'related' field usually points to the serial numbers of other records within refbase.  It can take arbitrary text input, but the links to related records would break & it would just be another textual field.

       
    • Matthias Steffens

      In addition to hard-coded record serial numbers, the related field does also except "dynamic" pointers such as:

      author:lee; title:ecosystem

      or even raw SQL query clauses (or a mix of these). More info is available in our wiki:

      http://wiki.refbase.net/index.php/Relating_records_to_each_other

      However, it may well be that you're trying something that is best done using another refbase field or feature. For example, you can include file paths to local files in the 'user_file' field. And the 'file' field does accept and works with full http://, https:// or ftp:// URLs to remote locations. These can be entered by the admin user.

      We may be able to provide more help if you explain in more detail what you're trying to accomplish.

      Best regards, Matthias

       
    • Knut Krüger

      Knut Krüger - 2007-03-28

      I changed the part of the related link to:

      // generate a link from the RELATED field:
      if (isset($_SESSION['loginEmail'])) // if a user is logged in, show a link to any related records (if available):
      {
      if (!empty($row["related"]))
      {
      echo $row["related"];                                                    
      $relatedRecordsLink = buildRelatedRecordsLink($row["related"], $userID);
      if (eregi("localhost", $row["related"])) //detect whether contains a local ftp file f.e to use with XAMPP
      $linkArray[] = "\n\t\t<a href=\&quot;" . encodeHTML($row["related"]) . "\&quot;><img src=\&quot;img/related.gif\&quot; alt=\&quot;related\&quot; title=\&quot;display related records\&quot; width=\&quot;19\&quot; height=\&quot;16\&quot; hspace=\&quot;0\&quot; border=\&quot;0\&quot;></a>";
      else                                                       
      $linkArray[] = "\n\t\t<a href=\&quot;" . $relatedRecordsLink . "\&quot;><img src=\&quot;img/related.gif\&quot; alt=\&quot;related\&quot; title=\&quot;display related records\&quot; width=\&quot;19\&quot; height=\&quot;16\&quot; hspace=\&quot;0\&quot; border=\&quot;0\&quot;></a>";

      It works partially I have only the probelm that the base url from  RefBase is added before the string.

      mayby anybody could tell me at which part i could ask second time for localhost.

      If not I must look for ...

      Regards Knut
                                                          }
                                                      }

                                 

       
    • Knut Krüger

      Knut Krüger - 2007-03-28

      uups answered before I read your answer.
      We have too many pdf files at local HD or netword HD.
      There is no enoug place to store them on the Internet Server  and its against copyright.
      , so we would like to enable a feature for each user (and therefore for all user including external user) to include the filename of the local copy paper to the record.

      With this feature every one could add where their copies are stored.

      Regards Knut

       
    • Matthias Steffens

      Hi Knut,

      re. the 'related' field and your issue with the base URL: You could hack the 'related' field for this (as you've tried above). But I wouldn't recommend this, since this field serves an entirely purpose. So your hack will probably never be supported by an official refbase release, which means you'd need to re-enable your hack with every upgrade. That said, search for '$filesBaseURL' in 'search.php'. At two locations in this script, the base URL gets assigned.

      Am I understanding you correctly that you want individual refbase users to be able to store the location of their own (local) PDF copies together with the record meta data?

      If so, there IS actually a dedicated field for this exact purpose: it's the 'user_file' field. This field belongs to the user-specific fields (the "yellow" ones) which are individual for each user (and can only be viewed by its own user). People can store the name (or path) to their local PDF copy there. There's currently no magic performed with the data that's entered by the user in that field (like automatic link generation). But I'm happy to improve this if necessary.

      Matthias

       
    • Knut Krüger

      Knut Krüger - 2007-03-28

      found it now it works
      if there is a file with localhost then it will be redirected to the local apache from Xammp

      // generate a link from the RELATED field:
      if (isset($_SESSION['loginEmail'])) // if a user is logged in, show a link to any related records (if available):
      {
      if (!empty($row["related"]))
      {
      $relatedRecordsLink = buildRelatedRecordsLink($row["related"], $userID);
      if (eregi("localhost", $row["related"])) //detect whether contains a local ftp file f.e to use with XAMPP
      $linkArray[] = "\n\t\t<a href=\&quot;http://" . encodeHTML($row["related"]) . "\&quot;><img src=\&quot;img/related.gif\&quot; alt=\&quot;related\&quot; title=\&quot;display related records\&quot; width=\&quot;19\&quot; height=\&quot;16\&quot; hspace=\&quot;0\&quot; border=\&quot;0\&quot;></a>";
      else                                                       
      $linkArray[] = "\n\t\t<a href=\&quot;" . $relatedRecordsLink . "\&quot;><img src=\&quot;img/related.gif\&quot; alt=\&quot;related\&quot; title=\&quot;display related records\&quot; width=\&quot;19\&quot; height=\&quot;16\&quot; hspace=\&quot;0\&quot; border=\&quot;0\&quot;></a>";

      }
      }

      Dow you think there is any solution for direct access to HD or is it a security problem?
      maybe if  (eregi("c:\&quot;, $row["related"]))  //don't know how to build in the backslash

      Regards Knut

       
      • Matthias Steffens

        Just to repeat my warning: this hack won't be supported by refbase. If I'm not mistaken, this is exactly what the 'user_file' field is made for and that field should be improved instead.

        On Mac OS X you can prefix absolute file paths with 'file:///' to open the given file from within a browser. However, I don't know whether this is supported on all platforms and browsers. I also have no further knowledge about any security issues involved with this. Others may know more about this. At a minimum, a solution to open local files must work equally well on all platforms.

        If this is something that can be added easily, I'll be more than happy to provide this feature, but it should definitively use the 'user_file' field, not the 'related' field.

        Matthias

         
    • Knut Krüger

      Knut Krüger - 2007-03-28

      the same as before both of us answered the same time ;-)

      In my opinion it would be fine to implement this feature.
      I think a lot of user will have their own paper collection at ther working place.
      We have the collection mapped over Network and also mapped at the PC where thy are stored.
      So we could use the same path f.e L:/pdf-files/paper1.pdf

      It's no problem to manage this with XAMPP at the Pc where the data are stored, but it would be better to get access direct to the local or network directory.
      But I heard about security problems to enable direct HD access.

      Regards Knut

       
    • Knut Krüger

      Knut Krüger - 2007-03-28

      I am just figure out how to implement the link with the user_file. I started with the related file because there was already an icon on the right side.
      just now I do not find the content of the user_file field ,,, but I am searching ;-)
      Regards Knut

       
    • Knut Krüger

      Knut Krüger - 2007-03-28

      // generate a link from the user_file field:
      if (!empty($row["user_file"]))
      {
      if (eregi("localhost", $row["related"])) //detect whether contains a local ftp file f.e to use with XAMPP maybe 127.1.1.0 should be added

      $linkArray[] = "\n\t\t<a href=\&quot;http://" . encodeHTML($row["user_file"]) . "\&quot;><img src=\&quot;img/local.gif\&quot; alt=\&quot;User Key\&quot; title=\&quot;display User Key records\&quot; width=\&quot;19\&quot; height=\&quot;16\&quot; hspace=\&quot;0\&quot; border=\&quot;0\&quot;></a>";

      else    //detect whether contains a local HD file

      $linkArray[] = "\n\t\t<a href=\&quot;file://" . encodeHTML($row["user_file"]) . "\&quot;><img src=\&quot;img/local.gif\&quot; alt=\&quot;User Key\&quot; title=\&quot;display User Key records\&quot; width=\&quot;19\&quot; height=\&quot;16\&quot; hspace=\&quot;0\&quot; border=\&quot;0\&quot;></a>";
      }
      //The image local.gif is only at my refBase just now
         
      Hi Matthias                           
      Code works, but the browser opens only the file if there is a locelhost file.
      Otherwise if the file is on a local HD its only with working - copy link -
      Paste into browser
      Ok not as expected but usable.
      maybe anybody knows why.

      Regards Knut

      Do you think We could fill in the datas in the User_file field and it will be implemented?

      Regards Knut

       
      • Matthias Steffens

        Hi Knut,

        Using the 'file://...' links I get the same behaviour as you describe. The links are not clickable, however, copying them and pasting them into the browser's location bar works.

        Note that the "detection" logic which you use in your posted code won't always do the right thing. What if a file name (or directory path) contains 'localhost' in its name (or path spec, respectively)? Similarly, by prefixing everything else with 'file://' you assume that people always input full paths.

        Btw, using full paths in the 'user_file' field is somewhat messy since the field's contents are displayed on the details page. Having long path specs in that field is possible but visually not very pleasing.

        Here's another proposal: I'd drop the idea of providing direct links to arbitrary locations on the user's harddisk. Instead, I'd recommend that you instruct your users to put all their local files into a single directory (having sub-dirs within that user-specific files base dir would be fine, of course).

        Then, users could specify the base URL to their local files base directory on the refbase user options page. Ideally, this would be the path to a local web directory, such as <http://localhost/~msteffens/>. If they don't have a local web dir, they could still enter something like 'file:///path/to/my/files/dir/'. But obviously, the first one would be much more useful.

        This setup would allow users to simply specify the file name (or file path) *relative* to their base dir within the 'user_file' field. Using the above given local web dir as an example:

        'user_file' contains  -> resolves to
        --------------------  --------------
        paper1.pdf            -> http://localhost/~msteffens/paper1.pdf
        topicA/paper2.pdf     -> http://localhost/~msteffens/topicA/paper2.pdf
        topicB/               -> http://localhost/~msteffens/topicB/

        Being able to specify file/folder paths relative to a user-specific base dir would be the better approach (IMHO), since it wouldn't mess so much with the layout of the details page, and it would be easy to specify another base directory later on.

        What do you (and others) think about this?

        Matthias

         
    • Knut Krüger

      Knut Krüger - 2007-03-28

      Maybe you could use both.
      Any user radiobutton to choose complete paths or localhost apache installation.
      if the directory structure is equal you could choose localhost:
      the localhost root is f.e c:\literature\msteffens

      paper1.pdf -> http://localhost/ice/paper1.pdf
      paper2.pdf -> http://localhost/clouds/paper2.pdf

      ore if they choose file you could either write down the full path:
      c:\literature\msteffens\ice\paper1.pdf
      or (i would prefere) a mapped drive)
      f.e
      L:\ice\paper1.pdf
      L:\clouds\paper2.pdf

      In that case it is easy to map the hole file structure so that the user is able to use the links from all PCs

      in case one the http:// is default in front
      in case two file:// is in front.

      The most of the user will not have a localhost and they will never have a locolhost at a CIP-POOL station.
      But they could have a mapped directory.

      With Regards Knut

       
      • Matthias Steffens

        I'm not following you. Could you rephrase?

        Wouldn't a plain text field on the user's options page cater for all these conditions? The user would simply enter a path spec in that options field that would work for her, be it 'http://localhost/...', 'file:///...' or 'L:\...'.

        Note that, in my proposal, the resolved path (user base dir + relative path spec from the 'user_file' field) would still be only available via a link icon in the "Links" column in details view. This would be consistent and rather unobtrusive, IMHO.

        M.

         
    • Knut Krüger

      Knut Krüger - 2007-03-29

      Hi Matthias

      1. Reason
      I don't know wheter it is possbile to switch bewteen all possbile operating systems with only a text field. I think the our database will be used from Linux, Mac, and Windows.

      2. one user could fill in the path with localhost, another could get access with network device.
      3. just now I am using from the file [Durschuchen] option and i am copiing the string to the user file field. (a [Durchsuchen] think it is [Search] on english systems for that field would be fine.
      In this case the full path is stored in the user file field, but without the file://.
      So it is impossible to copy and paste the path into the browser. Therefore I added the file:// as default.

      maybe there could be an option:
      If nothing is choosed the blank text field is used.
      I know the more options the more errors, but it is also more useful.
      The next step could be to exchange some parts of the string with another,
      different for each user.
      f.e change
      input path is L:\directory1\directory2\file
      exchange to L:\directory1\ localhost\

      And the last suggestion:
      use an include file to implement this feature. In this case anybody could change his import function without being aware about any updates and rehacking the big file.
      I am sure we will use network names and I will rechange the code after each update if the feature will not be implemented.

      By the way: is anybody else using a local apache server except me and Matthias?
      Maybe we are discussing about 0.005% of all users  in case of the localhost option ;-)

      knut

       
    • Matthias Steffens

      Hi Knut,

      I'm not yet convinced that all of your options are required, especially if you instruct your users to input a *relative* file path instead. If their relative path spec is, say, "directory2\file", they could easily switch the base dir to "L:\directory1\&quot; or "localhost" via the options page, no internal replacement actions would be required.

      I also think that this will probably not be the most used refbase feature. We have to find a middle path between useful features and complexity (feature bloat). That said and if my co-developers agree, I'm willing to implement a simple system (like I've outlined earlier in this thread). But there would be no additional file upload button (to get the file path), not many options (and only options on the options page), i.e. the layout of the "Add Record" form would stay as is. Using an include file is a good suggestion, however, everybody has its own pet feature and we'd need to provide every bit of code as an include file to make everyone happy (which, obviously, isn't going to happen).

      Actually, I can imagine that my proposed feature addition is all what your users would need. Let's start simple and let's try to keep it simple. Also note that by using the refbase placeholder variables, the relative file path could be even auto-generated for the user. However, this would require that the user uses a fixed naming scheme for his local PDF files (many people do).

      Matthias

       
    • Knut Krüger

      Knut Krüger - 2007-03-29

      Hi Matthias,
      I think the best idea is, as you told the simple system with an include file.
      So if anybody needs more its his (my) part to implement.

      I aggree that you are not able to build everything which one user will use ;-)

      I did SW developement more than 10 years and I know those problems ---

      REgards Knut

       
    • Knut Krüger

      Knut Krüger - 2007-06-06

      Hi Matthias,
      working a couple of weeks with the "local files" and with my new code part I would lke to report the results.
      maybe it is helpful:
      We realized that the base path depends not on the user - it depends on the computer.
      So I decided to store the base path into a cookie.
      Now it works very good. We are able to use all kind of paths:
      Any CD/DVD device   Cookie value: f.e D:\path_to_basedir
      mapped network paths Cookie value:  L:\path_to_basedir
      - and - the best for my home ;-)
      The apache server of the main workstation in the local windows network.
      Cookie value : http://192.168.22.165/db

      Regards Knut

      if (!empty($row["user_file"]))
      {  
      if ($_COOKIE["User_file_path_for_Refdb"]== "")
         $linkArray[] = "\n\t\t<a href=\&quot;setcookie.html\&quot;><img src=\&quot;img/local.gif\&quot; alt=\&quot;User Key\&quot; title=\&quot;display User Key records\&quot;                                                       width=\&quot;19\&quot; height=\&quot;16\&quot; hspace=\&quot;0\&quot; border=\&quot;0\&quot;></a>";
      else
      {if (ereg("http", $_COOKIE["User_file_path_for_Refdb"] )) 
         $linkArray[] = "\n\t\t<a href=\&quot;" . $_COOKIE['User_file_path_for_Refdb']. strtr( encodeHTML($row['user_file']),'\\','/')."\&quot;><img src=\&quot;img/local.gif\&quot; alt=\&quot;User Key\&quot; title=\&quot;display User Key records\&quot; width=\&quot;19\&quot; height=\&quot;16\&quot; hspace=\&quot;0\&quot; border=\&quot;0\&quot;></a>" ;
      else   
      $linkArray[] = "\n\t\t<a href=\&quot;" . $_COOKIE['User_file_path_for_Refdb'].        encodeHTML($row['user_file'])          . "\&quot;><img src=\&quot;img/local.gif\&quot; alt=\&quot;User Key\&quot; title=\&quot;display User Key records\&quot; width=\&quot;19\&quot; height=\&quot;16\&quot; hspace=\&quot;0\&quot; border=\&quot;0\&quot;></a>";
      }               
      }           
                 

       

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks