paths, include
pz - December 3, 2006 - 01:41
| Project: | Pdfview |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | task |
| Priority: | minor |
| Assigned: | Unassigned |
| Status: | needs review |
Description
In the code below (from pdfview_node) the second require is redundant since that is the first thing that tcpdf.php does.
function pdfview_node($node) {
$path = drupal_get_path('module', 'pdfview');
require_once($path . '/tcpdf/tcpdf.php');
require_once($path . '/tcpdf/config/tcpdf_config.php');What is more important/annoying is that the config file sets the path with a define which forces me to edit the config file everytime I set up a new site. Wouldn't it be possible to define the path before inclusion instead,
function pdfview_node($node) {
$path = drupal_get_path('module', 'pdfview');
define('K_PATH_MAIN', $path . '/tcpdf/');
require_once($path . '/tcpdf/tcpdf.php');I have this working on a testinstallation but haven't really tested if it causes any sideeffects.

#1
That's the first thing I considered when I switched pdfview to tcpdf, I considered also to make a settings page to tweak those defines. However, since there is a lot of constants needed for the rendering, I opted for leaving them in the config file.
One other way to deal with the thing is to put all of theme inside the theme_pdfview_pdf function, but honestly using theme function is a hack I'd like to get rid of somehow ...
#2
I think it is not bad to define the constants in our module so that nobody has to modify the config file
This patch is the first step: define the constants and create drupal variables for them
later, we could create a settings page, so a user can overwrite them easily.
I skipped a few of the constants, because they sound useless (like cache or image)
One thing we should investigate is which of the constants are really needed and which one are not needed.
And then replace these unneeded constants directly with the variables.