/** If the class does not exist, try to include it
* @param string $className name of the class
* @param $dir application folder path
* For each class name inclusion is first tried from $thisfunction (->(),
* If the class is not found, a class from the classes root folder is tried.
* However, this behavior may be overridden on Site::getTryUseClassTryParams
* @return boolean wheather a class file was included. Also true if the class already existed.
*/
function tryUseClass($className, $dir) {
if (strlen($className) > Gen::$CLASS_MAX_LENGTH)
throw new PntValidationException("$this - class name too long: '$className'");
$this->($className);
pntCheckIncludePath($dir);
$params = $this->($className, $dir);
$included = Gen::tryIncludeClass($params[0][0], $params[0][1]); //tryUseClass
//print "<BR>tryIncludeClass(".$params[0][0].", ". $params[0][1].") $included";
if (!$included) {
$included = Gen::tryIncludeClass($params[1][0], $params[1][1]); //tryUseClass
//print "<BR>tryIncludeClass(".$params[1][0].", ". $params[1][1].") $included";
}
return $included;
}
|