Project

General

Profile

Feature #17720 ยป t3lib_div.diff

Administrator Admin, 2007-10-24 17:48

View differences:

class.t3lib_div.php (copie de travail)
* @return object A reference to the object
*/
public static function &makeInstance($className) {
// Load class file if not found:
t3lib_div::dynClassLoad($className);
// Load class file if not found:
if (!class_exists($className)) {
if (substr($className,0,6)=='t3lib_') {
t3lib_div::requireOnce(PATH_t3lib.'class.'.strtolower($className).'.php');
}
}
// Get final classname
$className = t3lib_div::makeInstanceClassName($className);
......
return new $className;
}
/**
* Dynamic class load : native suppor of t3lib / tslib classes, other classes have to be declared into
* $TYPO3_CONF_VARS['CLASS_REGISTER'] ( $TYPO3_CONF_VARS['CLASS_REGISTER'][<classname>] = <pathToFile> )
*
* @param string $className = the class to load
* @access static
* @return bool = true if class exists after processing
*/
function dynClassLoad($className) {
/* Declare */
global $TYPO3_CONF_VARS;
$fileName = null;
/* Begin */
if (class_exists($className)) {
// Nothing to do
return true;
} elseif (substr($className, 0, 6) == 't3lib_') {
// t3lib classes
$fileName = PATH_t3lib . 'class.' . $className . '.php';
} elseif (substr($className, 0, 6) == 'tslib_') {
// tslib classes
$fileName = t3lib_extMgm::extPath('cms', 'tslib/' . 'class.' . $className . '.php');
} elseif (isset($TYPO3_CONF_VARS['CLASS_REGISTER'][$className])) {
// Other classes
$fileName = t3lib_div::getFileAbsFileName($TYPO3_CONF_VARS['CLASS_REGISTER'][$className]);
}
if (!is_null($fileName) && $fileName) {
t3lib_div::requireOnce($fileName);
}
return class_exists($className);
}
/**
* Return classname for new instance
* Takes the class-extensions API of TYPO3 into account
* Usage: 17
    (1-1/1)