Beispiel #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.
  */
 public static function _($type)
 {
     $type = preg_replace('#[^A-Z0-9_\\.]#i', '', $type);
     // Check to see if we need to load a helper file
     $parts = explode('.', $type);
     $prefix = count($parts) == 3 ? array_shift($parts) : 'JHtml';
     $file = count($parts) == 2 ? array_shift($parts) : '';
     $func = array_shift($parts);
     $key = strtolower($prefix . '.' . $file . '.' . $func);
     if (array_key_exists($key, self::$registry)) {
         $function = self::$registry[$key];
         $args = func_get_args();
         // remove function name from arguments
         array_shift($args);
         return JHtml::call($function, $args);
     }
     $className = $prefix . ucfirst($file);
     if (!class_exists($className)) {
         jimport('joomla.filesystem.path');
         if ($path = JPath::find(JHtml::$includePaths, strtolower($file) . '.php')) {
             require_once $path;
             if (!class_exists($className)) {
                 JError::raiseError(500, $className . '::' . $func . ' not found in file.');
                 return false;
             }
         } else {
             JError::raiseError(500, $prefix . $file . ' not supported. File not found.');
             return false;
         }
     }
     $toCall = array($className, $func);
     if (is_callable($toCall)) {
         JHtml::register($key, $toCall);
         $args = func_get_args();
         // remove function name from arguments
         array_shift($args);
         return JHtml::call($toCall, $args);
     } else {
         JError::raiseError(500, $className . '::' . $func . ' not supported.');
         return false;
     }
 }
Beispiel #2
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  $key   The name of helper method to load, (prefix).(class).function
  *                         prefix and class are optional and can be used to load custom
  *                         html helpers.
  *
  * @return   mixed  JHtml::call($function, $args) or False on error
  * @since    11.1
  */
 public static function _($key)
 {
     list($key, $prefix, $file, $func) = self::extract($key);
     if (array_key_exists($key, self::$registry)) {
         $function = self::$registry[$key];
         $args = func_get_args();
         // Remove function name from arguments
         array_shift($args);
         return JHtml::call($function, $args);
     }
     $className = $prefix . ucfirst($file);
     if (!class_exists($className)) {
         jimport('joomla.filesystem.path');
         if ($path = JPath::find(JHtml::$includePaths, strtolower($file) . '.php')) {
             require_once $path;
             if (!class_exists($className)) {
                 JError::raiseError(500, JText::sprintf('JLIB_HTML_ERROR_NOTFOUNDINFILE', $className, $func));
                 return false;
             }
         } else {
             JError::raiseError(500, JText::sprintf('JLIB_HTML_ERROR_NOTSUPPORTED_NOFILE', $prefix, $file));
             return false;
         }
     }
     $toCall = array($className, $func);
     if (is_callable($toCall)) {
         JHtml::register($key, $toCall);
         $args = func_get_args();
         // Remove function name from arguments
         array_shift($args);
         return JHtml::call($toCall, $args);
     } else {
         JError::raiseError(500, JText::sprintf('JLIB_HTML_ERROR_NOTSUPPORTED', $className, $func));
         return false;
     }
 }