Commit ac56545f authored by Nigel McNie's avatar Nigel McNie
Browse files

[UPSTREAM] Added support for Pieforms' 'template' functionality.

This is done by providing a function that form writers need to call to get the template directory. This function scans through the theme directories following the inheritance chain. This allows templates to be overrideable by theme.
parent deb4792e
......@@ -365,6 +365,10 @@ function error ($code, $message, $file, $line, $vars) {
if (E_NOTICE == $code && substr($file, 0, strlen($compiledir)) == $compiledir) {
return;
}
if (E_NOTICE == $code && preg_match('#^' . quotemeta(get_config('docroot') . 'theme/') . '[a-z0-9-]+/pieforms#', $file)) {
return;
}
}
// Fix up the message, which is in HTML form
......
......@@ -1273,6 +1273,31 @@ function pieform_element_textarea_configure($element) {
return $element;
}
/**
* Should be used to provide the 'templatedir' directive to pieforms using a
* template for layout.
*
* This depends on theme_setup(), so potentially should be in lib/web.php, but
* for now it lives with the other pieform functions.
*
* @param string $file The file to be used as a pieform template, e.g.
* "admin/site/files.php". This is the value you used as
* the 'template' option for your pieform
* @param string $pluginlocation Which plugin to search for the template, e.g.
* artefact/file
*/
function pieform_template_dir($file, $pluginlocation='') {
$theme = theme_setup();
foreach ($theme->inheritance as $themedir) {
$filepath = get_config('docroot') . $pluginlocation . 'theme/' . $themedir . '/pieforms/' . $file;
if (is_readable($filepath)) {
return dirname($filepath);
}
}
throw new SystemException('No pieform template available: ' . $file);
}
/**
* Given a view id, and a user id (defaults to currently logged in user if not
* specified) will return wether this user is allowed to look at this view.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment