Open funderburkjim opened 5 years ago
The Dictinfo::get_pdfpages_url() method described above is the key to the current server agnostic solution provided by ServepdfClass in servepdfClass.php.
Here are the steps used to get a URL for the scanned image of a particular page of a particular dictionary. Assume that strings representing the page and dictionary are in variables $page
and $dict
in an ServepdfClass instance.
$dictinfo = new Dictinfo($dict);
.$pdfpages_url = $dictinfo->get_cologne_pdfpages_url();
.getfiles
method to get the $filename corresponding to $page (see pdffiles.txt comment above):
list($filename,$pageprev,$pagenext)=$this->getfiles($pdffiles_filename,$page,$dictupper);
In the web/webtc directory for each dictionary there is a file named pdffiles.txt.
This file is NOT maintained by csl-websanlexicon, but must be present in order for the display of scanned images if the scanned images are on the server.
This file is used by the getfiles
method of the ServepdfClass instance. This method returns the filename corresponding to a page number for a particular scanned image.
Each dictionary digitization has
The pdffiles.txt file lists the correspondences between page reference and file name. The getfiles method is responsible for matching a given page reference to one of those in pdffiles.txt, and thus determining the filename corresponding to the given page reference.
The pdffiles.txt lines are assumed to be in the order of the text. This permits the getfiles method to also return the filenames corresponding to the scanned images of the page preceding and following the given page reference. These two file names in turn permit the 'next' and 'previous' arrow controls that are part of the scanned image display generated by servepdf.
$dictinfowhich
The dictinfowhich.php module defines a PHP variable $dictinfowhich whose value provides a run-time switch used to distinguish the server running the application.
Currently, $dictinfowhich has one of two string values, "cologne" or "xampp" (see
server agnostic enhancement intro
comment above).If the file system name of the current directory (provided by the PHP constant
__DIR__
) starts with 'afs', then the value is set to "cologne"; otherwise it is set to "xampp". The test could be made more precise if and when the need arises.Dictinfo::get_pdfpages_url()
This method in dictinfo.php returns a string used (by ServepdfClass) to construct a URL string for a scanned image of a particular page in a particular dictionary.
get_pdfpages_url() uses the value of $dictinfowhich to tailor the computation depending on the server type.
../pdfpages
and../../pdfpages
. The first path which is a non-empty directory on the server is assumed to be the one to use, and is the value returned.flexibility of cologne solution
Currently, the cologne url is the pdfpages directory within the 'old' web directory, e.g. for VCP, the url is //www.sanskrit-lexicon.uni-koeln.de/scans/VCPScan/2013/web/pdfpages
When we construct a new version of the dictionary, in VCPScan/2020/, we can still use //www.sanskrit-lexicon.uni-koeln.de/scans/VCPScan/2013/web/pdfpages. i.e., the same url will work for the old VCPScan/2013 and the new VCPScan/2020.
Also, if we decide to change the location of the cologne images for any (or all) dictionaries, this can be accomplished by changing the get_cologne_pdfpages_url() function in the Dictinfo class in dictinfo.php.