[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pear-general
Subject:    [PEAR] Autoload solution to __PHP_Incomplete_Class - Re: [PEAR] Can
From:       Andrew Wooldridge <andrew.r.wooldridge () vanderbilt ! edu>
Date:       2005-06-29 17:02:39
Message-ID: BEE83E5F.1400%andrew.r.wooldridge () vanderbilt ! edu
[Download RAW message or body]

Uhh that didn't work.

require_once('/usr/lib/php/HTML/QuickForm/Controller.php');
require_once('/usr/lib/php/DB/DataObject/FormBuilder.php');
require_once('/usr/lib/php/HTML/QuickForm.php');
require_once('DB/DataObject/FormBuilder/QuickForm.php');

// Load some default action handlers
require_once( 'HTML/QuickForm/Action/Next.php');
require_once( 'HTML/QuickForm/Action/Back.php');
require_once( 'HTML/QuickForm/Action/Jump.php');
require_once( 'HTML/QuickForm/Action/Display.php');
require_once( 'HTML/QuickForm/Action/Submit.php');

      //a handy string function that returns everything in the string after
your query
      //example after('abc','abcdef'); returns 'def'
      function after ($thisone, $inthat)
     {
            if (!is_bool(strpos($inthat, $thisone)))
            return substr($inthat,
strpos($inthat,$thisone)+strlen($thisone));
    };

    //function __autoload($classname)
    //this function gets called when a class is come across that has not
been included yet
    //there are two locations for classes that this program uses.
    //the first is the DataObjects directory containing the autogenerated
DataObject classes
    //that were created with createTables.php
//and prepended with class_prefix from DataObject.ini
    //the second is the PEAR library repository.  Per PEAR conventions, the
class name will
    //determine where the file is located in the PEAR hierarchy.
    //example HTML_QuickForm_Header class is located at the path
HTML/QuickForm/header.php
    // NOTE: required classes above are the ones that don't follow this
convention.
    
    function __autoload($className)
    {    
        
         $config = parse_ini_file('DataObject.ini',TRUE);
         $dataObjectClassPrefix =
{$config["DB_DataObject"]["class_prefix"]};
        $dataObjectDirectoryPath =
{$config["DB_DataObject"]["class_location"]};
        
        #echo $className."\n".$dataObjectClassPrefix."\n".strpos($className,
$dataObjectClassPrefix)."<br>\n\n\n";
        
        if (!(strpos($className, $dataObjectClassPrefix) === false))
        {
            require_once
$dataObjectDirectoryPath.after($dataObjectClassPrefix,$className) . '.php';
            
        }
        else
        {
            require_once str_replace('_', '/', $className).'.php';
        }
    }
    ?>

-- 
PEAR General Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic