#16 real relative PATHS for layersmenu-common

closed
nobody
None
5
2004-08-18
2004-08-18
MicAttAck
No

This is a patch for layersmenu-common.inc.php.
Since I wanted to have the script reside in
include\phplayersmenu-3.2.0\ I had some problems
moving the example-hormenu.php to another directory
(like the documentation suggested)

I modified the construcor of LayersMenuCommon, so that
it automatically finds the right path. This should now
always work, without any more user intervention.

function LayersMenuCommon()
{
$this->_packageName = 'PHP Layers Menu';
$this->version = '3.2.0-rc';
$this->copyright = '(C) 2001-2004';
$this->author = 'Marco Pratesi - http://www.
marcopratesi.it/';

$this->prependedUrl = '';
/* dirname(__FILE__) gets the Directory of the
current file
since we know, this is a library, we can cut of the
lib/ at the end (4 characters) */
$this->dirroot = substr(dirname(__FILE__),0,
strlen(dirname(__FILE__))-3);
/* The WWWroot for our files is the same as dirroot,
just without the document root.
e.g: /var/www/html/include/phplayersmenu-3.2.0/
DOCUMENT_ROOT: /var/www/html
We can simply cut of the right number of
characters from the front of the String */
$wwwroot = substr($this->dirroot,
strlen($_SERVER['DOCUMENT_ROOT']));
$this->libjsdir = $this->dirroot . './libjs/';
$this->imgdir = $this->dirroot . 'menuimages/';
$this->imgwww = $wwwroot . 'menuimages/';
$this->icondir = $this->dirroot . 'menuicons/';
$this->iconwww = $wwwroot . 'menuicons/';
$this->tpldir = $this->dirroot . 'templates/';

Discussion

  • Marco Pratesi
    Marco Pratesi
    2004-08-18

    • status: open --> closed
     
  • Marco Pratesi
    Marco Pratesi
    2004-08-18

    Logged In: YES
    user_id=65709

    > real relative PATHS for layersmenu-common

    This subject is misleading, as PHPLM
    already provides usage with both
    relative and absolute paths.

    > This is a patch for layersmenu-common.inc.php.

    No, this is not a patch, in fact there is
    not any patch attached to this report:

    "No Files Currently Attached"

    > the script reside in include\phplayersmenu-3.2.0\

    "include\phplayersmenu-3.2.0\" is neither
    a directory nor a path, maybe you refer to
    "include/phplayersmenu-3.2.0/".

    > since we know, this is a library, we can cut of the
    > lib/ at the end (4 characters) */

    Not true: I can put the PHPLM library files
    in a directory that has a different name,
    as in PgMarket, i.e. lib/phplayersmenu/

    > $this->dirroot = substr(dirname(__FILE__),0,
    > strlen(dirname(__FILE__))-3);

    A more reasonable choice could be

    $this->dirRoot = dirname(__FILE__) . '/../';

    but this would be wrong too if the PHPLM
    lib files are put in lib/phplayersmenu/ :
    in this case '/../' should be replaced
    by '/../../'

    > The WWWroot for our files is the same as dirroot,
    > just without the document root.

    Not necessarily; you can configure Apache
    in a different way for a directory tree
    and BTW you can even put the libs outside
    the web directory tree.

    Anyway, PHPLM already provides
    all methods to set the path whatever way
    you want, and the manual and the examples
    completely and clearly explain how to
    set paths, hence IMO no patch is needed
    to add features already provided
    and documented.
    Furthermore, the setDirrootCommon()
    and setDirroot() methods already forsesee
    updating of all other paths consequently;
    but maybe you do not have even read
    the code before trying to change it >:-)

    Marco Pratesi