function fft_get_templates in Field Formatter Template 7
Same name and namespace in other branches
- 8.2 fft.module \fft_get_templates()
- 8 fft.module \fft_get_templates()
Get avaiables templates.
Return value
array List of Field formatter template.
2 calls to fft_get_templates()
- fft_field_formatter_settings_form in ./
fft.module - Implements hook_field_formatter_settings_form().
- fft_field_formatter_settings_summary in ./
fft.module - Implements hook_field_formatter_settings_summary().
File
- ./
fft.module, line 130 - Field formatter template.
Code
function fft_get_templates() {
static $page_templates = NULL;
if (!$page_templates) {
$files = file_scan_directory(fft_store_dir(), '/^.*\\.php$/');
foreach ($files as $full_path => $file) {
$file_content = file_get_contents($full_path);
$header = array();
if (!preg_match('|Template Name:(.*)$|mi', $file_content, $header)) {
continue;
}
$template_file = str_replace(fft_store_dir() . "/", '', $file->uri);
$page_templates['templates'][$template_file] = fft_cleanup_header_comment($header[1]);
$settings = array();
if (preg_match('%/\\*Settings:(.*?)\\*/%s', $file_content, $settings)) {
$page_templates['settings'][$template_file] = trim($settings[1]);
}
}
}
return $page_templates;
}