コード例 #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
ファイル: themes.php プロジェクト: Nerus87/PsychoStats
    // reinstall a local theme already on the hard drive
    $dir = basename($dir);
    // remove any potentially malicous paths
    if (file_exists(catfile($newtheme->template_dir, $dir))) {
        $t = $newtheme->reinstall($dir);
        if ($t) {
            $message = $cms->message('success', array('message_title' => "Theme reinstalled successfully!", 'message' => "Theme \"" . $t->xml_title() . "\" was installed successfully and is now available for use."));
        } else {
            $message = $cms->message('theme-failure', array('message_title' => "Error reinstalling theme", 'message' => $newtheme->error()));
        }
    } else {
        $message = $cms->message('theme-failure', array('message_title' => "Error installing theme", 'message' => "Theme not found!"));
    }
} elseif ($submit and $url and $allow['install']) {
    // attempt to install new theme if one is submitted
    $newtheme->load_theme($url);
    if ($newtheme->error()) {
        $submit = false;
        if ($newtheme->code() != PSTHEME_ERR_XML) {
            $message = $cms->message('theme-failure', array('message_title' => "Error installing theme", 'message' => $newtheme->error()));
        } else {
            $message = $cms->message('theme-failure', array('url' => $url, 'invalid' => $newtheme->invalid_list()));
        }
    }
    // if there are no errors and 'confirm' was specified then install the theme
    if ($submit and $confirm) {
        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()));