public function site_templates($options = false)
{
$args = func_get_args();
$function_cache_id = '';
foreach ($args as $k => $v) {
$function_cache_id = $function_cache_id . serialize($k) . serialize($v);
}
$cache_id = __FUNCTION__ . crc32($function_cache_id);
$cache_group = 'templates';
$cache_content = false;
// $cache_content = $this->app->cache_manager->get($cache_id, $cache_group);
if ($cache_content != false) {
// return $cache_content;
}
if (!isset($options['path'])) {
$path = templates_path();
} else {
$path = $options['path'];
}
$path_to_layouts = $path;
$layout_path = $path;
$map = $this->directory_map($path, true, true);
$to_return = array();
if (!is_array($map) or empty($map)) {
return false;
}
foreach ($map as $dir) {
//$filename = $path . $dir . DIRECTORY_SEPARATOR . 'layout.php';
$filename = $path . DIRECTORY_SEPARATOR . $dir;
$filename_location = false;
$filename_dir = false;
$filename = normalize_path($filename);
$filename = rtrim($filename, '\\');
$filename = substr($filename, 0, 1) === '.' ? substr($filename, 1) : $filename;
if (!@is_file($filename) and @is_dir($filename)) {
$fn1 = normalize_path($filename, true) . 'config.php';
$fn2 = normalize_path($filename);
if (is_file($fn1)) {
$config = false;
include $fn1;
if (!empty($config)) {
$c = $config;
$c['dir_name'] = $dir;
$screensshot_file = $fn2 . '/screenshot.png';
$screensshot_file = normalize_path($screensshot_file, false);
if (is_file($screensshot_file)) {
$c['screenshot'] = $this->app->url_manager->link_to_file($screensshot_file);
}
$to_return[] = $c;
}
} else {
$filename_dir = false;
}
// $path = $filename;
}
}
//$this->app->cache_manager->save($to_return, $cache_id, $cache_group, 'files');
return $to_return;
}