function create_hash() { # .htaccess file $htaccess = file_exists('./.htaccess') ? '.htaccess:'.filemtime('./.htaccess') : ''; # serialize the file cache $file_cache = serialize(Helpers::file_cache()); # create an md5 of the two collections return md5($htaccess.$file_cache); }
static function collate_partials($dir = './templates/partials') { foreach(Helpers::file_cache($dir) as $file) { if($file['is_folder']) { self::collate_partials($file['path']); } else { self::$partials[] = $file['path']; } } }
static function collate_partials($dir = false) { if (!$dir) { $dir = Config::$templates_folder . '/partials'; } foreach (Helpers::file_cache($dir) as $file) { if ($file['is_folder']) { self::collate_partials($file['path']); } else { self::$partials[] = $file['path']; } } }
function __construct($file_path, $template_file) { # generate an md5 hash from the file_path $this->path_hash = $this->generate_hash($file_path); # generate an md5 hash from the current state of the site content $htaccess = file_exists(Config::$root_folder . '.htaccess') ? '.htaccess:' . filemtime(Config::$root_folder . '.htaccess') : ''; $file_cache = serialize(Helpers::file_cache()); $content_hash = $this->generate_hash($htaccess . $file_cache); # combine the two hashes to create a cachefile name $this->cachefile = Config::$cache_folder . '/pages/' . $this->cache_prefix . $this->path_hash . '-' . $content_hash; # store the hash $this->hash = $this->cache_prefix . $this->path_hash . '-' . $content_hash; }
function create_full_cache($pages = null) { $search_fields = array('url', 'file_path', 'title', 'author', 'content'); $store = array(); if (!isset($pages)) { $pages = Helpers::file_cache('./content'); } foreach ($pages as $page) { if ($page['is_folder']) { $current_page = AssetFactory::get($page['path']); # Skip for password protected pages if ($current_page['password_protect'] || $current_page['hide_from_search']) { continue; } # Only save search field data foreach ($current_page as $key => $value) { if (!in_array($key, $search_fields)) { unset($current_page[$key]); } } $store[] = $current_page; $children = self::create_full_cache(Helpers::file_cache($page['path'])); if (is_array($children)) { $store = array_merge($store, $children); } } } return $store; }
function create_full_cache($pages = null) { $search_fields = array('url', 'file_path', 'title', 'author', 'content', 'object_name', 'designer', 'builder', 'category', 'tags', 'contributors', 'realisation_place', 'required_hardware', 'license', 'client'); $store = array(); if (!isset($pages)) { $pages = Helpers::file_cache('./content'); } foreach ($pages as $page) { if ($page['is_folder']) { $current_page = AssetFactory::get($page['path']); # Skip for password protected pages if (isset($current_page['password_protect']) || isset($current_page['hide_from_search'])) { continue; } # Only save search field data foreach ($current_page as $key => $value) { if (!in_array($key, $search_fields)) { unset($current_page[$key]); } } $store[] = $current_page; $children = self::create_full_cache(Helpers::file_cache($page['path'])); if (is_array($children)) { $store = array_merge($store, $children); } } } return $store; }