コード例 #1
0
 /**
  * Class loader method
  *
  * Additional arguments may be supplied and are passed to the sub-class.
  * Additional include paths are also able to be specified for third-party use
  *
  * @param	string	The name of helper method to load, (prefix).(class).function
  *                  prefix and class are optional and can be used to load custom
  *                  html helpers.
  * @throws KViewException
  */
 public static function _($type)
 {
     //Initialise variables
     $prefix = 'KViewHelper';
     $file = '';
     $func = $type;
     // Check to see if we need to load a helper file
     $parts = explode('.', $type);
     switch (count($parts)) {
         case 3:
             $prefix = ucfirst($parts[0]) . 'Helper';
             $file = $parts[1];
             $func = $parts[2];
             break;
         case 2:
             $prefix = 'KViewHelper';
             $file = $parts[0];
             $func = $parts[1];
             break;
     }
     $className = $prefix . ucfirst($file);
     if (!class_exists($className)) {
         jimport('joomla.filesystem.path');
         if ($path = JPath::find(KViewHelper::getIncludePaths(), $file . '.php')) {
             require_once $path;
             if (!class_exists($className)) {
                 throw new KViewException($className . '::' . $func . ' not found in file.');
             }
         } else {
             throw new KViewException($prefix . $file . ' not supported. File not found.');
         }
     }
     if (!is_callable(array($className, $func))) {
         throw new KViewException($className . '::' . $func . ' not supported.');
     }
     $args = func_get_args();
     array_shift($args);
     return call_user_func_array(array($className, $func), $args);
 }