function getTemplates($path = false) { if (!$path) { $path = 'inc/html/' . conf('Server', 'default_template_set'); } $templates = array('' => 'Inherit', 'default' => 'Default'); loader_import('saf.File.Directory'); $dir = new Dir(); if (!$dir->open($path)) { return $templates; } foreach ($dir->read_all() as $file) { if (strpos($file, '.') === 0 || @is_dir($path . '/' . $file)) { continue; } if (preg_match('/^html.([^\\.]+)\\.tpl$/', $file, $regs)) { if ($regs[1] == 'default') { continue; } $templates[$regs[1]] = ucfirst($regs[1]); } } asort($templates); return $templates; }
function getThemes($path = false) { if (!$path) { $path = site_docroot() . '/inc/app/sitepresenter/themes'; } $themes = array(); //'' => 'Default'); loader_import('saf.File.Directory'); $dir = new Dir(); if (!$dir->open($path)) { return $themes; } foreach ($dir->read_all() as $file) { if (strpos($file, '.') === 0 || !@is_dir($path . '/' . $file)) { continue; } //if (preg_match ('/^html.([^\.]+)\.tpl$/', $file, $regs)) { //if ($regs[1] == 'default') { // continue; //} $themes[$file] = ucfirst($file); //} } return $themes; }