本文整理汇总了PHP中JFormHelper::addPath方法的典型用法代码示例。如果您正苦于以下问题:PHP JFormHelper::addPath方法的具体用法?PHP JFormHelper::addPath怎么用?PHP JFormHelper::addPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JFormHelper
的用法示例。
在下文中一共展示了JFormHelper::addPath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadClass
/**
* Load a class for one of the form's entities of a particular type.
* Currently, it makes sense to use this method for the "field" and "rule" entities
* (but you can support more entities in your subclass).
*
* @param string $entity One of the form entities (field or rule).
* @param string $type Type of an entity.
*
* @return mixed Class name on success or false otherwise.
*
* @since 11.1
*/
protected static function loadClass($entity, $type)
{
$class = 'JForm' . ucfirst($entity) . ucfirst($type);
if (class_exists($class)) {
return $class;
}
// Get the field search path array.
$paths = JFormHelper::addPath($entity);
// If the type is complex, add the base type to the paths.
if ($pos = strpos($type, '_')) {
// Add the complex type prefix to the paths.
for ($i = 0, $n = count($paths); $i < $n; $i++) {
// Derive the new path.
$path = $paths[$i] . '/' . strtolower(substr($type, 0, $pos));
// If the path does not exist, add it.
if (!in_array($path, $paths)) {
array_unshift($paths, $path);
}
}
// Break off the end of the complex type.
$type = substr($type, $pos + 1);
}
// Try to find the class file.
if ($file = JPath::find($paths, strtolower($type) . '.php')) {
include_once $file;
}
// Check for all if the class exists.
return class_exists($class) ? $class : false;
}
示例2: loadClass
/**
* Load a class for one of the form's entities of a particular type.
* Currently, it makes sense to use this method for the "field" and "rule" entities
* (but you can support more entities in your subclass).
*
* @param string $entity One of the form entities (field or rule).
* @param string $type Type of an entity.
*
* @return mixed Class name on success or false otherwise.
*
* @since 11.1
*/
protected static function loadClass($entity, $type)
{
if (strpos($type, '.')) {
list($prefix, $type) = explode('.', $type);
} else {
$prefix = 'J';
}
$class = JString::ucfirst($prefix, '_') . 'Form' . JString::ucfirst($entity, '_') . JString::ucfirst($type, '_');
if (class_exists($class)) {
return $class;
}
// Get the field search path array.
$paths = JFormHelper::addPath($entity);
// If the type is complex, add the base type to the paths.
if ($pos = strpos($type, '_')) {
// Add the complex type prefix to the paths.
for ($i = 0, $n = count($paths); $i < $n; $i++) {
// Derive the new path.
$path = $paths[$i] . '/' . strtolower(substr($type, 0, $pos));
// If the path does not exist, add it.
if (!in_array($path, $paths)) {
$paths[] = $path;
}
}
// Break off the end of the complex type.
$type = substr($type, $pos + 1);
}
// Try to find the class file.
$type = strtolower($type) . '.php';
foreach ($paths as $path) {
if ($file = JPath::find($path, $type)) {
require_once $file;
if (class_exists($class)) {
break;
}
}
}
// Check for all if the class exists.
return class_exists($class) ? $class : false;
}