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; }
$res = 'failure'; $msg = $cms->trans("Error writting to database: %s", $ps->db->errstr); } } } if ($msg) { $message = $cms->message($res, array('message_title' => $title, 'message' => $msg)); } } // load the themes $list = $ps->db->fetch_rows(1, "SELECT * FROM {$ps->t_config_themes} " . $ps->getsortorder($_order)); $total = $ps->db->count($ps->t_config_themes); $themes = array(); foreach ($list as $t) { if ($t['parent']) { $themes[$t['parent']]['children'][] = $t; } else { $themes[$t['name']] = $t; $themes[$t['name']]['children'] = array(); } } $pager = pagination(array('baseurl' => ps_url_wrapper(array('sort' => $sort, 'order' => $order, 'limit' => $limit)), 'total' => $total, 'start' => $start, 'perpage' => $limit, 'pergroup' => 5, 'separator' => ' ', 'force_prev_next' => true, 'next' => $cms->trans("Next"), 'prev' => $cms->trans("Previous"))); $cms->crumb("Themes", ps_url_wrapper()); // assign variables to the theme $cms->theme->assign(array('url' => $url, 'allow' => $allow, 'newtheme' => $newtheme->theme_xml(), 'theme_dirs' => $newtheme->theme_dirs(), 'themes' => $themes, 'total_themes' => $total, 'submit' => $submit, 'confirm' => $confirm, 'page' => basename(__FILE__, '.php'))); // display the output $basename = basename(__FILE__, '.php'); $cms->theme->add_css('css/forms.css'); $cms->theme->add_js('js/themes.js'); $cms->theme->add_js('js/message.js'); $cms->full_page($basename, $basename, $basename . '_header', $basename . '_footer', '');