mirror of
https://github.com/e107inc/e107.git
synced 2025-08-05 14:17:49 +02:00
Added getProperty() method.
This commit is contained in:
@@ -954,6 +954,23 @@ class e_library_manager
|
|||||||
return $directories;
|
return $directories;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns with the selected property of a library.
|
||||||
|
*
|
||||||
|
* @param string $library
|
||||||
|
* Library machine name. For example: bootstrap
|
||||||
|
*
|
||||||
|
* @param string $property
|
||||||
|
* The property name. For example: library_path
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getProperty($library, $property)
|
||||||
|
{
|
||||||
|
$lib = self::info($library);
|
||||||
|
return varset($lib[$property], false);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns information about registered libraries.
|
* Returns information about registered libraries.
|
||||||
*
|
*
|
||||||
@@ -1003,48 +1020,32 @@ class e_library_manager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gather information from THEME_library::config().
|
$themes[] = array(
|
||||||
$siteTheme = e107::getPref('sitetheme');
|
'name' => e107::getPref('sitetheme'),
|
||||||
$adminTheme = e107::getPref('admintheme');
|
'file' => 'theme_library',
|
||||||
|
'class' => 'theme_library',
|
||||||
|
);
|
||||||
|
|
||||||
|
$themes[] = array(
|
||||||
|
'name' => e107::getPref('admintheme'),
|
||||||
|
'file' => 'admin_theme_library',
|
||||||
|
'class' => 'admin_theme_library',
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach($themes as $theme)
|
||||||
foreach(array($siteTheme, $adminTheme) as $theme)
|
|
||||||
{
|
{
|
||||||
if(is_readable(e_THEME . $theme . '/theme_library.php')) // we don't use e_XXXX for themes.
|
if(is_readable(e_THEME . $theme['name'] . '/' . $theme['file'] . '.php'))
|
||||||
{
|
{
|
||||||
e107_require_once(e_THEME . $theme . '/theme_library.php');
|
e107_require_once(e_THEME . $theme['name'] . '/' . $theme['file'] . '.php');
|
||||||
|
|
||||||
$className = 'theme_library';
|
$info = e107::callMethod($theme['class'], 'config');
|
||||||
if(class_exists($className)) //@todo replace with e107::callMethod();
|
if(is_array($info))
|
||||||
{
|
{
|
||||||
$addonClass = new $className();
|
foreach($info as $machine_name => $properties)
|
||||||
|
|
||||||
if(method_exists($addonClass, 'config'))
|
|
||||||
{
|
{
|
||||||
$info = $addonClass->config();
|
$properties['info_type'] = 'theme';
|
||||||
if(is_array($info))
|
$properties['theme'] = $theme['name'];
|
||||||
{
|
$libraries[$machine_name] = $properties;
|
||||||
foreach($info as $machine_name => $properties)
|
|
||||||
{
|
|
||||||
$properties['info_type'] = 'theme';
|
|
||||||
$properties['theme'] = $theme;
|
|
||||||
$libraries[$machine_name] = $properties;
|
|
||||||
|
|
||||||
if(!in_array($theme, $themes))
|
|
||||||
{
|
|
||||||
$themes[] = $theme; // This theme has a valid e_library implementation.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(method_exists($addonClass, 'config_alter'))
|
|
||||||
{
|
|
||||||
if(!in_array($theme, $themes))
|
|
||||||
{
|
|
||||||
$themes[] = $theme; // This theme has a valid e_library implementation.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1070,18 +1071,21 @@ class e_library_manager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allow enabled themes (with theme_library.php file) to alter the registered libraries.
|
// Allow enabled themes to alter the registered libraries.
|
||||||
foreach($themes as $theme)
|
foreach($themes as $theme)
|
||||||
{
|
{
|
||||||
e107_require_once(e_THEME . $theme . '/theme_library.php');
|
if(is_readable(e_THEME . $theme['name'] . '/' . $theme['file'] . '.php'))
|
||||||
$addonClass = $theme . '_library';
|
|
||||||
|
|
||||||
if(class_exists($addonClass))
|
|
||||||
{
|
{
|
||||||
$class = new $addonClass();
|
e107_require_once(e_THEME . $theme['name'] . '/' . $theme['file'] . '.php');
|
||||||
if(method_exists($class, 'config_alter'))
|
|
||||||
|
if(class_exists($theme['class']))
|
||||||
{
|
{
|
||||||
$class->config_alter($libraries);
|
$class = new $theme['class']();
|
||||||
|
if(method_exists($class, 'config_alter'))
|
||||||
|
{
|
||||||
|
// We cannot use e107::callMethod() because need to pass variable by reference.
|
||||||
|
$class->config_alter($libraries);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class bootstrap3_library.
|
* Class theme_library.
|
||||||
*/
|
*/
|
||||||
class theme_library
|
class theme_library
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user