addBreadCrumb(['link' => ADMIN."theme.php".$aidlink, 'title' => self::$locale['theme_1000']]); } /** * Check if a theme widget file exist * * @param $theme_name * * @return bool */ static function theme_widget_exists($theme_name) { return (is_dir(THEMES.$theme_name) && file_exists(THEMES.$theme_name."/widget.php")) ? TRUE : FALSE; } /** * The Theme Editor - Manage UI * * @param $theme_name */ public static function display_theme_editor($theme_name) { $locale = fusion_get_locale(); $aidlink = fusion_get_aidlink(); // sanitize theme exist $theme_name = self::verify_theme($theme_name) ? $theme_name : ""; if (!$theme_name) { redirect(clean_request("", ["aid"], TRUE)); } BreadCrumbs::getInstance()->addBreadCrumb(['link' => FUSION_REQUEST, 'title' => $locale['theme_1018']]); // go with tabs $tab['title'] = [$locale['theme_1022'], $locale['theme_1023'], $locale['theme_1024']]; $tab['id'] = ["dashboard", "widgets", "css"]; $tab['icon'] = ["fa fa-edit fa-fw", "fa fa-cube fa-fw", "fa fa-css3 fa-fw"]; if (isset($_GET['action'])) { $tab['title'][] = $locale['theme_1029']; $tab['id'][] = "close"; $tab['icon'][] = "fa fa-close fa-fw"; } if (isset($_POST['close_theme'])) { redirect(FUSION_SELF.$aidlink); } $_GET['section'] = isset($_GET['section']) && in_array($_GET['section'], $tab['id']) ? $_GET['section'] : "dashboard"; $tab_active = $_GET['section']; $atom = new Atom(); $atom->target_folder = $theme_name; $atom->theme_name = $theme_name; echo opentab($tab, $tab_active, "theme_admin", TRUE, 'nav-tabs m-b-10'); // now include the thing as necessary switch ($_GET['section']) { case "dashboard": /** * Delete preset */ if (isset($_GET['delete_preset']) && isnum($_GET['delete_preset'])) { if (empty($_GET['theme'])) { redirect(FUSION_SELF.$aidlink); } $theme_name = stripinput($_GET['theme']); $file = dbarray(dbquery("SELECT theme_file FROM ".DB_THEME." WHERE theme_name='".$theme_name."' AND theme_id='".intval($_GET['delete_preset'])."'")); if (file_exists(THEMES.$file['theme_file'])) { unlink(THEMES.$file['theme_file']); } dbquery("DELETE FROM ".DB_THEME." WHERE theme_id='".intval($_GET['delete_preset'])."'"); addNotice('success', $locale['theme_success_002']); redirect(clean_request("", ["section", "aid", "action", "theme"], TRUE)); } /** * Set active presets */ if (isset($_POST['load_preset']) && isnum($_POST['load_preset'])) { $result = dbquery("select theme_id FROM ".DB_THEME." WHERE theme_active='1'"); if (dbrows($result) > 0) { $data = dbarray($result); $data = [ "theme_id" => $data['theme_id'], "theme_active" => 0, ]; dbquery_insert(DB_THEME, $data, "update"); } $data = [ "theme_id" => $_POST['load_preset'], "theme_active" => 1, ]; dbquery_insert(DB_THEME, $data, "update"); redirect(clean_request("", ["section", "aid", "action", "theme"], TRUE)); } $atom->display_theme_overview(); break; case "widgets": $atom->display_theme_widgets(); break; case "css": $atom->theme_editor(); break; case "close": redirect(FUSION_SELF.$aidlink); break; default: break; } echo closetab(); } /** * Verify theme exist * * @param $theme_name * * @return bool */ public static function verify_theme($theme_name) { return (is_dir(THEMES.$theme_name) && file_exists(THEMES.$theme_name."/theme.php") && file_exists(THEMES.$theme_name."/styles.css") && fusion_get_settings('theme') == $theme_name) ? TRUE : FALSE; } public static function display_theme_list() { $locale = fusion_get_locale(); $aidlink = fusion_get_aidlink(); $settings = fusion_get_settings(); if (isset($_GET['action']) && $_GET['action'] == "set_active" && isset($_GET['theme']) && $_GET['theme'] !== "") { $theme_name = form_sanitizer($_GET['theme'], ''); if (self::theme_installable($theme_name)) { $result = dbquery("UPDATE ".DB_SETTINGS." SET settings_value='".$theme_name."' WHERE settings_name='theme'"); if ($result) { redirect(FUSION_SELF.$aidlink); } } } $data = []; $_dir = makefilelist(THEMES, ".|..|templates|admin_themes", TRUE, "folders"); foreach ($_dir as $folder) { $theme_dbfile = '/theme_db.php'; $status = $settings['theme'] == $folder ? 1 : 0; if (file_exists(THEMES.$folder.$theme_dbfile)) { // 9.00 compatible theme. $theme_folder = ''; include_once THEMES.$folder.$theme_dbfile; $data[$status][$folder] = [ 'readme' => !empty($theme_readme) && file_exists(THEMES.$theme_folder."/".$theme_readme) ? THEMES.$theme_folder."/".$theme_readme : '', 'folder' => isset($theme_folder) && file_exists(THEMES.$theme_folder.'/theme.php') ? THEMES.$theme_folder : '', 'screenshot' => isset($theme_screenshot) && file_exists(THEMES.$theme_folder."/".$theme_screenshot) ? THEMES.$theme_folder."/".$theme_screenshot : IMAGES.'imagenotfound.jpg', 'title' => isset($theme_title) ? $theme_title : '', 'web' => isset($theme_web) ? $theme_web : '', 'author' => isset($theme_author) ? $theme_author : '', 'license' => isset($theme_license) ? $theme_license : '', 'version' => isset($theme_version) ? $theme_version : '', 'description' => isset($theme_description) ? $theme_description : '', 'widgets' => file_exists(THEMES.$theme_folder.'/widget.php') ? TRUE : FALSE ]; } else { // older legacy theme. if (file_exists(THEMES.$folder.'/theme.php')) { $theme_screenshot = '/screenshot.jpg'; $data[$status][$folder] = [ 'readme' => '', 'folder' => THEMES.$folder, 'title' => $folder, 'screenshot' => file_exists(THEMES.$folder.$theme_screenshot) ? THEMES.$folder.$theme_screenshot : IMAGES.'imagenotfound.jpg', 'author' => '', 'license' => '', 'version' => '', 'description' => $locale['theme_1035'] ]; } } } krsort($data); foreach ($data as $status => $themes) { foreach ($themes as $theme_name => $theme_data) { echo "