mysite_load_includes($type = NULL, $name = NULL, $load_all = FALSE)
mysite.module, line 3385
Load the desired includes for this action. This function is a conditional load of enabled MySite plugins. In the case of administration pages, all includes are always loaded.
$type The type of include to return (a string). If NULL, all will be returned.
$name The filename of a specific include to load (but not its file extension -- for security, we handle file extensions using a separate function).
$load_all A boolean flag for forcing the load of all includes of a given type; necessary in some conditions.
A simple array of include files that were loaded.
function mysite_load_includes($type = NULL, $name = NULL, $load_all = FALSE) {
if (!empty($type)) {
$mask = mysite_get_mask($type);
$path = drupal_get_path('module', 'mysite') .'/plugins';
$list = array();
switch ($type) {
case 'types':
$get_content = variable_get('mysite_content', NULL);
if ($load_all) {
$get_content = mysite_get_includes('types');
}
if (!empty($get_content)) {
foreach ($get_content as $key => $value) {
if (is_null($name)) {
// Value may be a name string or a complex data object.
if (is_string($value) || is_string($value->name)) {
$list[$key] = $value;
}
}
else if ($name == $key) {
$list[$key] = $value;
}
}
}
break;
default:
$list = mysite_get_includes($type, $name);
break;
}
}
if (!empty($list)) {
foreach ($list as $key => $value) {
if ($type == 'styles') {
drupal_add_css($path .'/styles/'. $value->name .'.css');
}
else {
include_once($path .'/'. $type .'/'. $key . $mask);
}
}
return array_keys($list);
}
// Error sequence
drupal_set_message(t('No content types are active for MySite. Please notify the site administrator.'), 'error');
return array();
}