예제 #1
0
 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;
 }
예제 #2
0
         } else {
             $res = 'failure';
             $msg = $cms->trans("Error writting to database: %s", $ps->db->errstr);
         }
     }
 } elseif ($action == 'uninstall') {
     // do not uninstall the current theme, or any theme named 'default'
     if ($ps->conf['main']['theme'] == $t->xml_name() or $t->xml_name() == 'default') {
         $res = 'failure';
         $msg = $cms->trans("You can not uninstall the default or currently active theme!");
     } else {
         if (!$t->uninstall()) {
             $res = 'failure';
             $msg = $cms->trans("Error writting to database: %s", $ps->db->errstr);
         } else {
             $msg = $cms->trans("Theme '%s' was uninstalled successfully (note: directory was not deleted)", $t->xml_title());
         }
     }
 } else {
     $enabled = $action == 'enable' ? 1 : 0;
     if ($ps->conf['main']['theme'] == $t->xml_name() and !$enabled) {
         $res = 'failure';
         $title = $cms->trans("Operation Failed!");
         $msg = $cms->trans('You can not disable the active theme');
     } elseif ($t->enabled() != $enabled) {
         if ($t->toggle($enabled)) {
             $msg = $enabled ? $cms->trans("Theme '%s' was enabled", $t->xml_name()) : $cms->trans("Theme '%s' was disabled", $t->xml_name());
         } else {
             $res = 'failure';
             $msg = $cms->trans("Error writting to database: %s", $ps->db->errstr);
         }