function theme_dirs($dir = null) { if ($dir === null) { $dir = $this->template_dir; } if (!is_dir($dir)) { return false; } $list = array(); $dh = opendir($dir); if (!$dh) { return false; } while (($file = readdir($dh)) !== false) { if (!is_dir(catfile($dir, $file)) or substr($file, 0, 1) == '.') { continue; } // ignore non-directories and special list($installed) = $this->db->fetch_list("SELECT 1 FROM {$this->ps->t_config_themes} WHERE name LIKE " . $this->db->escape($file, true)); $xml = catfile($dir, $file, 'theme.xml'); if ($installed or !file_exists($xml)) { continue; } // ignore installed themes, or directories w/o a theme.xml $t = new PsychoThemeManager($this->ps, $this->template_dir); $t->load_theme($xml); $list[] = array('directory' => $file, 'installed' => $installed, 'title' => $t->xml_title() ? $t->xml_title() : $file, 'xml' => $t->theme_xml()); unset($t); } closedir($dh); return $list; }
if ($newtheme->install()) { $message = $cms->message('success', array('message_title' => "Theme installed successfully!", 'message' => "Theme \"" . $newtheme->xml_title() . "\" was installed successfully and is now available for use.")); } else { // theme did not install properly $message = $cms->message('failure', array('message_title' => "Error installing theme", 'message' => $newtheme->error())); } } } else { $submit = false; } // do something with an installed theme if (!empty($action)) { $action = strtolower($action); } if ($id and in_array($action, array('default', 'disable', 'enable', 'uninstall'))) { $t = new PsychoThemeManager($ps); if (!$t->load_theme_db($id)) { $cms->full_page_err(basename(__FILE__, '.php'), array('message' => $cms->trans("Invalid Theme Specified"))); exit; } $res = 'success'; $msg = ''; $title = $cms->trans("Operation was successful!"); if ($action == 'default') { if ($ps->conf['main']['theme'] != $t->xml_name()) { // don't do it if the current default matches the name $ok = $ps->db->query("UPDATE {$ps->t_config} SET value=" . $ps->db->escape($t->xml_name(), true) . " WHERE conftype='main' AND (section='' OR ISNULL(section)) AND var='theme'"); if ($ok) { $msg = $cms->trans("Theme '%s' is now the default theme", $t->xml_name()); $ps->conf['main']['theme'] = $t->xml_name(); // always make sure the new default theme is enabled