Re: Earthquake in Text_Wiki

From: Date: Thu, 27 May 2004 08:33:32 +0000
Subject: Re: Earthquake in Text_Wiki
References: 1 2  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-29747@lists.php.net to get a copy of this message
Zitat von Paul M Jones <pmjones@ciaweb.net>:
Hi, Jan,
This actually easier and faster than searching a whole set of paths.
This is good stuff. However, I'm not sure it will work in this particular case. Here's what makes me think so (and I may be wrong).
if (!empty($app)) { require_once $app . '/lib/Cache/' . $driver . '.php'; } elseif (@file_exists(dirname(__FILE__) . '/Cache/' . $driver . '.php')) { require_once dirname(__FILE__) . '/Cache/' . $driver . '.php'; } else { @include_once 'Horde/Cache/' . $driver . '.php'; }
OK, so: dirname(__FILE__) refers to the directory holding the current file. However, the problem I run into is how to get to the file in the first place.
You actually missed the interesting part of that construct. ;-) I talk about the first if-clause. Let's see where this $app variable comes from and take a look back at the start of the method:
    function &factory($driver, $params = array())
    {
        if (is_array($driver)) {
            $app = $driver[0];
            $driver = $driver[1];
        }
You actually have to ways to specify the driver, with or without the file location. You can call the factory like: $rule = &Text_Wiki_Rule::factory('Bold', $params); loading the default Bold rule that comes with Text_Wiki from Text/Wiki/Rule/Bold.php. But if you call it like: $rule = &Text_Wiki_Rule::factory(array('/home/jan/MyTextWiki', 'Bold'), $params); it could instead load the rule file from /home/jan/MyTextWiki/Rule/Bold.php or whatever path structure you chose in the first if-clause. In our APIs we expect custom drivers to be in lib/Package/driver.php but you can of course choose whatever you like or even let the user set the path to the driver file completely: $rule = &Text_Wiki_Rule::factory(array('/home/jan/MyTextWiki/Rule/Bold.php', 'Bold'), $params); Jan. -- Do you need professional PHP or Horde consulting? http://horde.org/consulting.php

« previous php.pear.dev (#29747) next »