/** * Standard modular run function for snippet hooks. Generates XHTML to insert into a page using AJAX. * * @return tempcode The snippet */ function run() { $theme = get_param('theme'); $equation = get_param('css_equation'); require_code('themewizard'); $css_path = get_custom_file_base() . '/themes/' . $theme . '/css_custom/global.css'; if (!file_exists($css_path)) { $css_path = get_file_base() . '/themes/default/css/global.css'; } $css_file_contents = file_get_contents($css_path, FILE_TEXT); $seed = find_theme_seed($theme); $dark = strpos($css_file_contents, '#000000; /* {$,wizard, 100% W/B} */') !== false; $colours = calculate_theme($seed, $theme, 'equations', 'colours', $dark); $parsed_equation = parse_css_colour_expression($equation); if (is_null($parsed_equation)) { return make_string_tempcode(''); } $answer = execute_css_colour_expression($parsed_equation, $colours[0]); if (is_null($answer)) { return make_string_tempcode(''); } return make_string_tempcode('#' . $answer); }
$theme = get_param('theme', NULL); if ($theme === NULL) { echo '<p>You must pick a theme…</p><ul>'; require_code('themes2'); $themes = find_all_themes(); foreach (array_keys($themes) as $theme) { if ($theme != 'default') { echo '<li><a href="' . static_evaluate_tempcode(build_url(array('page' => 'fix_partial_themewizard_css', 'theme' => $theme), 'adminzone')) . '">' . escape_html($theme) . '</a></li>'; } } echo '</ul>'; return; } $seed = find_theme_seed($theme); $dark = find_theme_dark($theme); $default_seed = get_param('force_default_seed', find_theme_seed('default')); if ($default_seed == $seed) { warn_exit('Theme has same seed as default theme, cannot continue, would be a no-op.'); } list($canonical_theme_map, $canonical_theme_landscape) = calculate_theme($default_seed, 'default', 'equations', 'colours', false); list($theme_map, $theme_landscape) = calculate_theme($seed, 'default', 'equations', 'colours', $dark); // === // CSS // === echo '<p>Made changes for:</p><ul>'; $dh = opendir(get_file_base() . '/themes/default/css'); while (($sheet = readdir($dh)) !== false) { if (substr($sheet, -4) == '.css') { $saveat = get_custom_file_base() . '/themes/' . filter_naughty($theme) . '/css_custom/' . $sheet; if (!file_exists($saveat)) { copy(get_file_base() . '/themes/default/css/' . $sheet, $saveat);
/** * Generate a theme image by converting an existing one to a new colour scheme via re-hueing. * * @param mixed The image path OR a preloaded GD image resource * @param string The colour code of our hue * @param ID_TEXT The theme this is being generated from * @param boolean Whether to also adjust the S and V components * @param boolean Whether to invert the colours * @return resource The image */ function re_hue_image($path, $seed, $source_theme, $also_s_and_v = false, $invert = false) { list($ocportal_h, $ocportal_s, $ocportal_v) = rgb_to_hsv(find_theme_seed($source_theme)); list($seed_h, $seed_s, $seed_v) = rgb_to_hsv($seed); $hue_dif = $seed_h - $ocportal_h; $sat_dif = $seed_s - $ocportal_s; $val_dif = $seed_v - $ocportal_v; if (is_string($path)) { if (function_exists('imagecreatefromgif') && substr($path, -4) == '.gif') { $_image = @imagecreatefromgif($path); } elseif (substr($path, -4) == '.jpg') { $_image = @imagecreatefromjpeg($path); } else { $_image = @imagecreatefrompng($path); } if ($_image === false) { warn_exit(do_lang_tempcode('CORRUPT_FILE', escape_html($path))); } } else { $_image = $path; } $width = imagesx($_image); $height = imagesy($_image); if (function_exists('imageistruecolor')) { if (function_exists('imagecreatetruecolor')) { if (!imageistruecolor($_image)) { $trans_colour = imagecolortransparent($_image); $image = imagecreatetruecolor($width, $height); imagecopy($image, $_image, 0, 0, 0, 0, $width, $height); } else { $image = $_image; $trans_colour = NULL; } } else { $image = $_image; $trans_colour = imagecolortransparent($_image); } } else { $image = $_image; $trans_colour = imagecolortransparent($_image); } imagealphablending($image, false); imagesavealpha($image, true); for ($y = 0; $y < $height; $y++) { for ($x = 0; $x < $width; $x++) { $_existing_colour = imagecolorat($image, $x, $y); $existing_colour = imagecolorsforindex($image, $_existing_colour); if (!is_null($trans_colour)) { $__existing_colour = imagecolorat($_image, $x, $y); if ($__existing_colour == $trans_colour) { $existing_colour['alpha'] = 127; } } $r = $existing_colour['red']; $g = $existing_colour['green']; $b = $existing_colour['blue']; $a = $existing_colour['alpha']; list($h, $s, $v) = rgb_to_hsv(str_pad(dechex($r), 2, '0', STR_PAD_LEFT) . str_pad(dechex($g), 2, '0', STR_PAD_LEFT) . str_pad(dechex($b), 2, '0', STR_PAD_LEFT)); if ($invert) { $v = 255 - $v; $v = min($v * 3, 255); // Because it's harder to see deviations of black } if ($seed_s < 10) { $s = $seed_s; } // To stop red colours for gray-scale images if ($also_s_and_v) { $sat_dif = 0; // Actually causes weirdness $result = hsv_to_rgb(floatval(fix_colour($h + $hue_dif, true)), floatval(fix_colour($s + $sat_dif)), floatval(fix_colour($v + $val_dif))); } else { $result = hsv_to_rgb(floatval(fix_colour($h + $hue_dif, true)), floatval($s), floatval($v)); } $new_colour_r = hexdec(substr($result, 0, 2)); $new_colour_g = hexdec(substr($result, 2, 2)); $new_colour_b = hexdec(substr($result, 4, 2)); if (function_exists('imagecolorallocatealpha')) { $target_colour = imagecolorallocatealpha($image, $new_colour_r, $new_colour_g, $new_colour_b, $a); } else { $target_colour = imagecolorallocate($image, $new_colour_r, $new_colour_g, $new_colour_b); } imagesetpixel($image, $x, $y, $target_colour); } } return $image; }
/** * The UI to manage themes. * * @return tempcode The UI */ function manage_themes() { $title = get_page_title('MANAGE_THEMES'); $GLOBALS['HELPER_PANEL_TEXT'] = comcode_lang_string('DOC_THEMES'); $zones = $GLOBALS['SITE_DB']->query_select('zones', array('*'), NULL, 'ORDER BY zone_title', 50); // Show all themes $_themes = find_all_themes(true); $site_default_theme = $GLOBALS['FORUM_DRIVER']->_get_theme(true); $themes = new ocp_tempcode(); $theme_default_reason = do_lang_tempcode('DEFAULT_THEME_BY_DEFAULT'); foreach ($_themes as $theme => $details) { if (is_integer($theme)) { $theme = strval($theme); } // Get URLs $css_url = build_url(array('page' => '_SELF', 'type' => 'choose_css', 'theme' => $theme), '_SELF'); $templates_url = build_url(array('page' => '_SELF', 'type' => 'edit_templates', 'theme' => $theme), '_SELF'); $images_url = build_url(array('page' => '_SELF', 'type' => 'manage_images', 'theme' => $theme), '_SELF'); $deletable = $theme != 'default'; $edit_url = build_url(array('page' => '_SELF', 'type' => 'edit_theme', 'theme' => $theme), '_SELF'); $delete_url = build_url(array('page' => '_SELF', 'type' => 'delete_theme', 'theme' => $theme), '_SELF'); $screen_preview_url = build_url(array('page' => '_SELF', 'type' => 'list', 'keep_theme' => $theme), '_SELF'); // Theme date $date = filemtime($theme == 'default' ? get_file_base() . '/themes/default' : get_custom_file_base() . '/themes/' . $theme); $_date = $theme == 'default' ? do_lang_tempcode('NA_EM') : protect_from_escaping(escape_html(get_timezoned_date($date, false))); // Where the theme is used $zone_list = new ocp_tempcode(); if ($theme == $site_default_theme) { $zone_list->attach(do_lang_tempcode('THEME_DEFAULT_FOR_SITE')); // Why is this the site-default theme? if ($theme == preg_replace('#[^\\w\\-\\.\\d]#', '_', get_site_name())) { $theme_default_reason = do_lang_tempcode('DEFAULT_THEME_BY_SITENAME'); } elseif ($theme != 'default') { $theme_default_reason = do_lang_tempcode('DEFAULT_THEME_BY_FORUM'); } } foreach ($zones as $zone) { if ($zone['zone_theme'] == $theme) { if (get_option('collapse_user_zones') == '1' && $zone['zone_name'] == 'site') { continue; } if (!$zone_list->is_empty()) { $zone_list->attach(do_lang_tempcode('LIST_SEP')); } $zone_list->attach($zone['zone_name']); } } if (!$zone_list->is_empty()) { $theme_usage = do_lang_tempcode('THEME_USED_ON', $zone_list); } else { $theme_usage = new ocp_tempcode(); } // Render $seed = NULL; if (addon_installed('themewizard')) { require_code('themewizard'); $seed = find_theme_seed($theme); } $themes->attach(do_template('THEME_MANAGE', array('_GUID' => 'c65c7f3f87d62ad425c7a104a6018840', 'SEED' => $seed, 'THEME_USAGE' => $theme_usage, 'DATE' => $_date, 'RAW_DATE' => strval($date), 'NAME' => $theme, 'DESCRIPTION' => $details['description'], 'AUTHOR' => $details['author'], 'TITLE' => $details['title'], 'CSS_URL' => $css_url, 'TEMPLATES_URL' => $templates_url, 'IMAGES_URL' => $images_url, 'DELETABLE' => $deletable, 'EDIT_URL' => $edit_url, 'DELETE_URL' => $delete_url, 'SCREEN_PREVIEW_URL' => $screen_preview_url))); } $zones = find_all_zones(false, true); require_lang('zones'); return do_template('THEME_MANAGE_SCREEN', array('_GUID' => '1dc277f18562976f6a23facec56a98e8', 'TITLE' => $title, 'THEMES' => $themes, 'THEME_DEFAULT_REASON' => $theme_default_reason, 'ZONES' => $zones)); }
/** * UI for a theme wizard step (choose colour). * * @return tempcode The UI */ function step1() { $title = get_page_title('_THEMEWIZARD', true, array(integer_format(1), integer_format(4))); $post_url = build_url(array('page' => '_SELF', 'type' => 'step2'), '_SELF', array('keep_theme_seed', 'keep_theme_dark', 'keep_theme_source', 'keep_theme_algorithm'), false, true); $text = do_lang_tempcode('THEMEWIZARD_1_DESCRIBE'); $submit_name = do_lang_tempcode('PROCEED'); require_code('form_templates'); $source_theme = get_param('source_theme', 'default'); $hidden = new ocp_tempcode(); if (count(find_all_themes()) == 1) { $hidden->attach(form_input_hidden('source_theme', $source_theme)); } else { $themes = nice_get_themes($source_theme, true); } $fields = new ocp_tempcode(); $fields->attach(form_input_codename(do_lang_tempcode('NEW_THEME'), do_lang_tempcode('DESCRIPTION_NAME'), 'themename', get_param('themename', ''), true)); $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => false, 'TITLE' => do_lang_tempcode('PARAMETERS')))); $fields->attach(form_input_colour(do_lang_tempcode('SEED_COLOUR'), do_lang_tempcode('DESCRIPTION_SEED_COLOUR'), 'seed', '#' . get_param('seed', find_theme_seed('default')), true)); if (count(find_all_themes()) != 1) { $fields->attach(form_input_list(do_lang_tempcode('SOURCE_THEME'), do_lang_tempcode('DESCRIPTION_SOURCE_THEME'), 'source_theme', $themes, NULL, true)); } $radios = new ocp_tempcode(); $radios->attach(form_input_radio_entry('algorithm', 'equations', $source_theme == 'default', do_lang_tempcode('THEMEGEN_ALGORITHM_EQUATIONS'))); $radios->attach(form_input_radio_entry('algorithm', 'hsv', $source_theme != 'default', do_lang_tempcode('THEMEGEN_ALGORITHM_HSV'))); $fields->attach(form_input_radio(do_lang_tempcode('THEMEGEN_ALGORITHM'), do_lang_tempcode('DESCRIPTION_THEMEGEN_ALGORITHM'), 'algorithm', $radios, true)); $fields->attach(form_input_tick(do_lang_tempcode('DARK_THEME'), do_lang_tempcode('DESCRIPTION_DARK_THEME'), 'dark', get_param_integer('dark', 0) == 1)); $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => true, 'TITLE' => do_lang_tempcode('ADVANCED')))); $fields->attach(form_input_tick(do_lang_tempcode('INHERIT_CSS'), do_lang_tempcode('DESCRIPTION_INHERIT_CSS'), 'inherit_css', get_param_integer('inherit_css', 0) == 1)); breadcrumb_set_self(do_lang_tempcode('THEMEWIZARD')); require_javascript('javascript_ajax'); $script = find_script('snippet'); $javascript = "\n\t\t\tvar form=document.getElementById('main_form');\n\t\t\tform.elements['source_theme'].onchange=function() {\n\t\t\t\tvar default_theme=(form.elements['source_theme'].options[form.elements['source_theme'].selectedIndex].value=='default');\n\t\t\t\tform.elements['algorithm'][0].checked=default_theme;\n\t\t\t\tform.elements['algorithm'][1].checked=!default_theme;\n\t\t\t}\n\t\t\tform.old_submit=form.onsubmit;\n\t\t\tform.onsubmit=function()\n\t\t\t\t{\n\t\t\t\t\tdocument.getElementById('submit_button').disabled=true;\n\t\t\t\t\tvar url='" . addslashes($script) . "?snippet=exists_theme&name='+window.encodeURIComponent(form.elements['themename'].value);\n\t\t\t\t\tif (!do_ajax_field_test(url))\n\t\t\t\t\t{\n\t\t\t\t\t\tdocument.getElementById('submit_button').disabled=false;\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\tdocument.getElementById('submit_button').disabled=false;\n\t\t\t\t\tif (typeof form.old_submit!='undefined' && form.old_submit) return form.old_submit();\n\t\t\t\t\treturn true;\n\t\t\t\t};\n\t\t"; return do_template('FORM_SCREEN', array('_GUID' => '98963f4d7ff60744382f937e6cc5acbf', 'GET' => true, 'SKIP_VALIDATION' => true, 'TITLE' => $title, 'JAVASCRIPT' => $javascript, 'FIELDS' => $fields, 'URL' => $post_url, 'TEXT' => $text, 'SUBMIT_NAME' => $submit_name, 'HIDDEN' => $hidden)); }
/** * Upgrade a theme automatically, using hand-coded migration arrays. * * @param ID_TEXT Theme to be upgraded * @param float From version * @param float Target version * @param boolean Whether executing a test run (i.e. not do anything) * @return array A pair: List of errors, List of successes */ function upgrade_theme($theme, $from_version, $to_version, $test_run = true) { $errors = array(); $successes = array(); if (!$test_run) { require_code('abstract_file_manager'); force_have_afm_details(); } $css_replace__single_match = array(); $css_prepend__single_match = array(); $css_append__single_match = array(); $css_replace__multi_match = array(); $css_prepend__multi_match = array(); $css_append__multi_match = array(); $css_file_append = array(); $theme_images_new = array(); $theme_images_renames = array(); $templates_replace = array(); $templates_rename = array(); $templates_borked = array(); if ($from_version < 8.0 && $to_version >= 8.0 && $to_version < 9.0) { $css_recognition_string = '2004-2011'; // Must be defined. Ensures theme is right version. $css_replace__multi_match = array('*' => array("2004-2011" => "2004-2012", "gradiant" => "gradient", "\$IMG," => "\$IMG;,", "url(\"" => "url('", "\")" => "')"), 'global.css' => array("comments_outer" => "comments_posting_form_outer", "comments_inner" => "comments_posting_form_inner", "comments_end" => "comments_posting_form_end", "comments_emoticons" => "comments_posting_form_emoticons", "comments_links" => "comments_posting_form_links")); $css_replace__single_match = array('adminzone.css' => array("template_edit_guid__true" => "template_edit_guid_1", "template_edit_guid__false" => "template_edit_guid_0"), 'calendar.css' => array(".calendar_week_hour {\n\twidth: 90px;\n}" => ".calendar_week_hour {\n\twidth: 90px;\n\theight: 30px;\n\tborder: 1px solid #6b81a1; /* {\$,dottedborder.border, 95% (seed sat_to 33) + 5% !W/B}*/\n}"), 'chat.css' => array(".chat_lobby_convos_area {\n}" => ".chat_lobby_convos_area {\n\toverflow: hidden;\n\twidth: 100%;\n}"), 'global.css' => array("tt, kbd, samp {\n\tfont-size: 1.25em;\n\tfont-weight: bold;\n}" => "tt, kbd, samp {\n\tfont-weight: bold;\n}", "input[type=\"text\"],input[type=\"password\"],textarea,select { /* Normally a browser default, but gets inherited on some phones */" => "input[type=\"text\"],input[type=\"password\"],input[type=\"color\"],input[type=\"email\"],input[type=\"number\"],input[type=\"range\"],input[type=\"search\"],input[type=\"tel\"],input[type=\"url\"],textarea,select { /* Normally a browser default, but gets inherited on some phones */", ".breadcrumbs {\n\tpadding: 5px 0 0 0;\n\tfloat: {!en_right};\n\tmargin-left: 5px;\n\tzoom: 1;\n}" => ".breadcrumbs {\n\tpadding: 5px 0 0 0;\n\t{+START,IF,{\$NOT,{\$MOBILE}}}\n\t\tfloat: {!en_right};\n\t\tmargin-left: 5px;\n\t{+END}\n\tzoom: 1;\n}\n\n.breadcrumbs abbr {\n\twhite-space: nowrap;\n}", ".standardbox_wrap_panel img {\n\tmax-width: 100%;\n}" => ".standardbox_wrap_panel img {\n\tmax-width: 98%;\n}", ".standardbox_classic, .standardbox_links_classic {" => ".standardbox_classic, .standardbox_wrap_classic .standardbox_links_classic {", ".scale_down { /* {\$,Membership of this class is used as a tag to turn on image scaling} */\n\tmax-width: 100%;\n}" => ".scale_down { /* {\$,Membership of this class is used as a tag to turn on image scaling} */\n\tmax-width: 100%;\n\tbox-sizing: border-box;\n}", "ul.compact_list {" => "ul.compact_list, ol.compact_list {", "ul.compact_list li {" => "ul.compact_list li, ol.compact_list li {", "ul.spaced_list, .spaced_list ul {" => "ul.spaced_list, .spaced_list ul, ol.spaced_list, .spaced_list ol {", ".trinav_right {\n\tfloat: right;\n\t{+START,IF,{\$NOT,{\$MOBILE}}}\n\t\tmargin-left: 10px;\n\t{+END}\n\t{+START,IF,{\$MOBILE}}\n\t\twidth: 33%;\n\t{+END}\n\ttext-align: right;\n}\n" => ".trinav_right {\n\tfloat: right;\n\t{+START,IF,{\$NOT,{\$MOBILE}}}\n\t\tmargin-left: 10px;\n\t\tmargin-right: 26px;\n\t{+END}\n\t{+START,IF,{\$MOBILE}}\n\t\twidth: 33%;\n\t{+END}\n\ttext-align: right;\n}\n", ".category_entry {\n\tpadding: 6px 0;\n\tmargin: 6px 0;\n\tclear: both;\n}" => ".category_entry {\n\tpadding: 6px 0;\n\tmargin: 6px 0;\n\tclear: both;\n\toverflow: hidden;\n\twidth: 100%;\n}", "ul.actions_list li, ul.actions_list_compact li, ul.actions_list_super_compact li {\n\tpadding: 0;\n\tmargin: 0;\n\tlist-style-type: none;\n}" => "ul.actions_list li, ul.actions_list_compact li, ul.actions_list_super_compact li {\n\tpadding: 0;\n\tmargin: 0;\n\tlist-style-type: none;\n\tlist-style-image: none;\n}", ".non_link:link,\n.non_link:visited,\n.non_link:hover,\n.non_link:active {\n\tcolor: #0d1522; /* {\$,wizard, 20% seed + 80% !W/B} */\n\ttext-decoration: none;\n\tcursor: default;\n}" => ".non_link,\n.non_link:link,\n.non_link:visited,\n.non_link:hover,\n.non_link:active {\n\tcolor: #0d1522 !important; /* {\$,wizard, 20% seed + 80% !W/B} */\n\ttext-decoration: none;\n\tcursor: default;\n}", "text-shadow: 1px 1px 1px #000000; /* {\$,wizard, 100% !W/B} */\n\tmargin: 0 2px;\n}" => "text-shadow: 1px 1px 1px #000000; /* {\$,wizard, 100% !W/B} */\n\tmargin: 0 2px;\n\toverflow: visible; /* stops button padding on IE7 */\n}", ".inline_image {\n\tvertical-align: top;\n}\n\n.inline_image_2 {\n\tvertical-align: middle;\n}\n\n.inline_image_3 {\n\tvertical-align: baseline;\n}\n\n.inline_image_4 {\n\tmargin-top: -4px;\n}" => ".inline_image {\n\tvertical-align: top !important;\n}\n\n.inline_image_2 {\n\tvertical-align: middle !important;\n}\n\n.inline_image_3 {\n\tvertical-align: baseline !important;\n}\n\n.inline_image_4 {\n\tmargin-top: -4px !important;\n}", ".gallery_media_full_expose {\n\toverflow: hidden;\n\twidth: 100%;\n\toutline: 0;\n\tmargin: {\$?,{\$MOBILE},1,3}em 0;\n}\n\n.gallery_media_full_expose {\n\ttext-align: center;\n}" => ".gallery_media_full_expose {\n\toverflow: hidden;\n\twidth: 100%;\n\toutline: 0;\n\tmargin: {\$?,{\$MOBILE},1,3}em 0;\n\ttext-align: center;\n\tposition: relative;\n}", ".gallery_media_full_expose img, .img_thumb {\n\tborder: 1px solid #6b81a1; /* {\$,wizard, 100% medborder.border} */\n\t-webkit-box-shadow: 3px 3px 10px #6b81a1; /* {\$,wizard, 100% medborder.border} */\n\t-moz-box-shadow: 3px 3px 10px #6b81a1; /* {\$,wizard, 100% medborder.border} */\n\tbox-shadow: 3px 3px 10px #6b81a1; /* {\$,wizard, 100% medborder.border} */\n\tmax-width: 100%;\n}" => ".gallery_media_full_expose img, .img_thumb {\n\tborder: 1px solid #6b81a1; /* {\$,wizard, 100% medborder.border} */\n\t-webkit-box-shadow: 3px 3px 10px #6b81a1; /* {\$,wizard, 100% medborder.border} */\n\t-moz-box-shadow: 3px 3px 10px #6b81a1; /* {\$,wizard, 100% medborder.border} */\n\tbox-shadow: 3px 3px 10px #6b81a1; /* {\$,wizard, 100% medborder.border} */\n\tmax-width: 100%;\n\tbox-sizing: border-box;\n}", ".form_field_name {\n\tmargin: 4px 0;\n}" => ".form_field_name {\n\tmargin: 4px;\n\tdisplay: inline-block;\n}", ".input_author, .input_username, .input_colour, .input_email,\n" => ".input_author, .input_username, .input_colour, .input_email, .input_codename,\n", ".input_author_required, .input_username_required, .input_colour_required, .input_email_required,\n" => ".input_author_required, .input_username_required, .input_colour_required, .input_email_required, .input_codename_required,\n", ".members_viewing {\n\tborder-top: 0;\n\tpadding: 4px;\n\ttext-indent: 25px;\n\tpadding-{!en_left}: 0;\n}" => ".members_viewing {\n\tpadding: 4px;\n\ttext-indent: 25px;\n\tpadding-{!en_left}: 0;\n}\n\n.ocf_topic_0 .members_viewing {\n\tborder-top: 0;\n}", ".post .post_edit_link {\n}" => ".post .post_action_link {\n}\n\n.post .post_thread_children {\n\tmargin-top: 1em;\n\t{+START,IF,{\$MOBILE}}\n\t\tmargin-left: 7px;\n\t{+END}\n\t{+START,IF,{\$NOT,{\$MOBILE}}}\n\t\tmargin-left: 20px;\n\t{+END}\n}\n\n.post .ocf_post_buttons {\n\tmargin-top: 1.3em;\n}\n\n.ocf_post_buttons a {\n\topacity: 0.0;\n\t-webkit-transition-property : opacity;\n\t-webkit-transition-duration : 0.5s;\n\t-moz-transition-property : opacity;\n\t-moz-transition-duration : 0.5s;\n\t-o-transition-property : opacity;\n\t-o-transition-duration : 0.5s;\n\ttransition-property : opacity;\n\ttransition-duration : 0.5s;\n}\n\n.ocf_post_buttons a[rel=\"add reply\"] {\n\topacity: 1.0;\n}\n\n.ocf_post_buttons:hover a {\n\topacity: 1.0;\n}\n\n.post_show_more {\n\ttext-align: center;\n\tborder: 1px dashed #c1cee3; /* {\$,wizard, 100% lightborder} */\n\tborder-bottom-left-radius: 40px;\n\tborder-bottom-right-radius: 40px;\n\tpadding: 15px;\n\tfont-weight: bold;\n\tfont-size: 0.85em;\n}\n\n.post .post_show_more {\n\tmargin-left: 20px;\n}", "ul.sitemap {\n\tlist-style-type: none;\n\tmargin-left: 0;\n\tpadding-left: 0;\n}" => "ul.sitemap {\n\tlist-style-type: none;\n\tlist-style-image: none;\n\tmargin-left: 0;\n\tpadding-left: 0;\n}", ".rating_inner {\n\ttext-align: center;\n\twhite-space: nowrap;\n}" => ".RATING_BOX .rating_inner {\n\ttext-align: center;\n}\n\n.RATING_INLINE_DYNAMIC .rating_inner, .RATING_INLINE_DYNAMIC form {\n\tdisplay: inline;\n}\n\n.post_action_link .RATING_INLINE_DYNAMIC {\n\tpadding-left: 20px;\n}\n\n.rating_inner {\n\twhite-space: nowrap;\n}\n\n.rating_inner img {\n\tcursor: pointer;\n}", ".tab {\n\tfloat: left;\n\tbackground: url('{\$IMG,tab}');\n\tpadding: 3px 5px 0 5px;\n\theight: 20px;\n\ttext-align: center;\n\tcursor: pointer;\n}" => ".tab {\n\tfloat: left;\n\tbackground: url('{\$IMG;,tab}') !important;\n\tpadding: 3px 7px 0 7px !important;\n\theight: 20px;\n\ttext-align: center;\n\tcursor: pointer;\n}", ".tab_active, .tab:hover {\n\tfont-weight: bold;\n}" => ".tab_active {\n\tfont-weight: bold;\n}\n\n.tab:hover {\n\ttext-decoration: underline !important;\n}", ".nl li {\n\tdisplay: block;\n\tmargin-{!en_left}: 0;\n\tpadding-{!en_left}: 0;\n\tlist-style-type: none;\n}" => ".nl li {\n\tdisplay: block;\n\tmargin-{!en_left}: 0;\n\tpadding-{!en_left}: 0;\n\tlist-style-type: none;\n\tlist-style-image: none;\n}", ".menu_type__popup li a:link a:hover {\n\tcolor: #9C202F; /* {\$,wizard, 100% a.hover}*/\n}" => ".menu_type__popup li a:hover {\n\tcolor: #9C202F !important; /* {\$,wizard, 100% a.hover}*/\n}", ".menu_type__top li, .menu_type__dropdown li.toplevel {\n\tfloat: {!en_left};\n\tborder-{!en_left}: 1px solid #0d1522; /* {\$,wizard, 20% seed + 80% !W/B} */\n\tmargin-{!en_right}: -1px;" => ".menu_type__top li, .menu_type__dropdown li.toplevel {\n\tfloat: {!en_left};\n\tborder-{!en_left}: 1px solid #0d1522; /* {\$,wizard, 20% seed + 80% !W/B} */\n\tmargin-{!en_right}: -1px;\n\tmargin-bottom: 0;", ".menu_type__top img, .menu_type__dropdown li.toplevel img {\n\tfloat: {!en_left};\n\tpadding: 0 8px 0 3px;\n\tmargin-top: -2px;\n}" => ".menu_type__top img, .menu_type__dropdown .toplevel_link img {\n\tmargin-top: -2px;\n}\n\n.menu_type__top img, .menu_type__dropdown img {\n\tfloat: {!en_left};\n\tpadding: 0 8px 0 3px;\n}", ".menu_type__top .menu_spacer, .menu_type__dropdown li.toplevel.menu_spacer {\n\theight: 1.15em;\n\twidth: 4em;\n\tpadding: 4px;\n}" => ".menu_type__top .menu_spacer, .menu_type__dropdown li.toplevel.menu_spacer {\n\theight: 1.15em;\n\twidth: 4em;\n\tpadding: 4px;\n\tfloat: {!en_left};\n}", ".menu_type__zone {\n\tfont-size: 0.9em;\n}" => ".menu_type__zone {\n\tfont-size: 0.9em;\n\tmax-height: 15px;\n}", ".menu_type__zone li {\n\tdisplay: inline;\n\tpadding: 0;\n\tlist-style-type: none;\n}" => ".menu_type__zone li {\n\tdisplay: inline;\n\tpadding: 0;\n\tlist-style-type: none;\n\tlist-style-image: none;\n}\n\n.menu_type__zone li * {\n\tvertical-align: middle;\n}", ".edit_menu_link_inline {\n\tposition: absolute;\n\tright: 1px;\n}" => "*>.edit_menu_link_inline {\n\tdisplay: none;\n}\n\n*:hover>.edit_menu_link_inline {\n\tdisplay: block;\n}\n\n.edit_menu_link_inline {\n\tposition: absolute;\n\tright: 1px;\n\tz-index: 10000;\n}", ".radio_list_picture {\n\tfloat: {!en_left};\n\twhite-space: nowrap;\n\tpadding: 3px;\n\tmin-width: 35px;\n\tmin-height: 35px;\n}" => ".radio_list_picture {\n\tfloat: {!en_left};\n\twhite-space: nowrap;\n\tpadding: 3px;\n\tmin-width: 40px;\n\tmin-height: 40px;\n\tfont-size: 0.8em;\n\tmin-height: 65px;\n\tmin-width: 85px;\n}"), 'news.css' => array(".standardbox_wrap_classic .news_piece_summary h3, .rss_summary h3 {\n\tmargin-{!en_right}: 130px;\n\tborder-bottom: 1px solid #6b81a1; /* {\$,wizard, 100% medborder.border} */\n}" => ".news_piece_summary h3, .rss_summary h3 {\n\tmargin-{!en_right}: 130px !important;\n\tborder-bottom: 1px solid #6b81a1 !important; /* {\$,wizard, 100% medborder.border} */\n}\n\n.rss_summary nobr { /* Stops naughty Google news from breaking layout */\n\twhite-space: normal;\n}"), 'ocf.css' => array(".ocf_post_details_date {\n\tfloat: {!en_left};\n\t{+START,IF,{\$NOT,{\$MOBILE}}}\n\t\twidth: 25em;\n\t{+END}\n\tpadding-{!en_left}: 4px;\n}" => ".ocf_post_details_date {\n\tfloat: {!en_left};\n\tpadding-{!en_left}: 4px;\n}\n\n.ocf_post_details_rating {\n\tfloat: {!en_left};\n\tpadding-{!en_left}: 20px;\n\twhite-space: nowrap;\n}", ".ocf_information_bar { /* {\$,either OCF_GUEST_BAR.tpl or OCF_MEMBER_BAR.tpl} */\n\tbackground-color: #eef2f7; /* {\$,wizard, 60% bgcol + 40% W/B} */\n\tfont-size: 0.85em;\n\tborder-collapse: collapse;\n\twhite-space: nowrap;\n\twidth: 100%;\n}" => ".ocf_information_bar { /* {\$,either OCF_GUEST_BAR.tpl or OCF_MEMBER_BAR.tpl} */\n\tbackground-color: #eef2f7; /* {\$,wizard, 60% bgcol + 40% W/B} */\n\tfont-size: 0.85em;\n\tborder-collapse: collapse;\n\twhite-space: nowrap;\n\twidth: 100%;\n\tpadding: 0;\n}", ".ocf_member_column_d {\n\t{+START,IF,{\$NOT,{\$MOBILE}}}\n\t\twidth: 11.3em;\n\t{+END}\n\t{+START,IF,{\$MOBILE}}\n\t\tfloat: left;\n\t{+END}\n\twhite-space: nowrap;\n}" => ".ocf_member_column_d {\n\twhite-space: nowrap;\n}", ".ocf_member_column_e {\n\twhite-space: nowrap;\n}\n\n" => "", ".ocf_post_details_unvalidated {\n\tfloat: {!en_left};\n\t}" => ".ocf_post_details_unvalidated {\n\tfloat: {!en_left};\n\tpadding-{!en_left}: 7px;\n\t}"), 'points.css' => array(".points_give_choices .sub_option {\n\tfont-size: 0.9em;\n}" => ".points_give_choices .sub_option {\n\tfont-size: 0.9em;\n\twhite-space: nowrap;\n}"), 'swfupload.css' => array("width: 365px;" => "{+START,IF,{\$NOT,{\$MOBILE}}}\n\t\twidth: 365px;\n\t{+END}"), 'tickets.css' => array(".closed_ticket {\n\tfont-weight: bold;\n\tpadding-{!en_left}: 30px;\n}" => ".closed_ticket {\n\tfont-style: italic;\n\tfloat: right;\n\tpadding-{!en_left}: 30px;\n}")); $css_prepend__single_match = array('adminzone.css' => array(".css_colour_strip" => ".dottedborder .css_colour_chooser_name {\n\twidth: 190px;\n}\n\n.dottedborder .css_colour_chooser {\n\twidth: 680px;\n\tmargin: 0;\n}\n\n", ".menu_editor_rh_side" => ".menu_editor_page.docked .menu_editor_rh_side {\n\toverflow-y: scroll;\n\tmax-height: 380px;\n\tmargin-right: 10px;\n}\n\n", ".menu_editor_lh_side" => ".menu_editor_page.docked #mini_form_hider {\n\tmargin-top: 1em;\n\tborder-top: 3px dotted #8b96df !important; /* {\$,wizard, 61% seed + 39% W/B} */\n\tposition: fixed;\n\tleft: 0;\n\tbottom: 0;\n\tbackground: #ffffff; /* {\$,wizard, 100% W/B} */\n\tfont-size: 0.9em;\n}\n\n.docked .menu_edit_main {\n\tpadding-bottom: 30em;\n}\n\n.dock_button {\n\tfloat: right;\n\tpadding: 5px;\n\tcursor: pointer;\n}\n\n"), 'calendar.css' => array(".top_navigation" => "abbr.dtstart, abbr.dtend {\n\tborder-bottom: 0;\n}\n\n"), 'galleries.css' => array(".nav_mid" => "#gallery_entry_screen {\n\twidth: 100%;\n\tmin-height: 100%;\n}\n\n", "/* side_root galleries block */" => ".slideshow_speed {\n\tposition: absolute;\n\tright: 0;\n\ttop: 0;\n}\n\n.slideshow_speed input {\n\twidth: 3em;\n}\n\n#changer {\n\tfont-weight: bold;\n\tfont-family: Courier;\n\tfont-size: 1.2em;\n}\n\n"), 'global.css' => array(".standardbox_title_classic a" => "h3.standardbox_title_classic {\n\tborder-bottom: 0;\n}\n\n", ".no_stbox_padding .dottedborder {" => ".overlay .dottedborder_huge_a, .overlay .dottedborder_barrier_a_nonrequired, .overlay .dottedborder_barrier_b_nonrequired, .overlay .dottedborder_divider, .overlay .dottedborder_divider_continue, .overlay .no_stbox_padding .forcedottedborder, .overlay .dottedborder {\n\tborder: 0;\n}\n\n", ".edited {" => ".bookmarks_menu_box {\n\twidth: 320px;\n}\n\n", "\na.poster_member:hover" => ".post_poster a.poster_member:link, .post_poster a.poster_member:active, .post_poster a.poster_member:visited, .post_poster a.poster_member:hover {\n\tdisplay: inline-block;\n}\n", ".menu_type__dropdown ul.nlevel, .menu_type__popup ul" => ".menu_type__popup {\n\tmin-width: 150px;\n}\n\n", ".comments_posting_form_inner table" => ".comments_posting_form_inner textarea {\n\tcolor: #94979d; /* {\$,wizard, 65% bgcol + 35% !W/B} */\n}\n\n")); $css_append__single_match = array('global.css' => array(".medborder_detailhead a:hover {\n\tcolor: #9C202F; /* {\$,wizard, 100% a.hover}*/\n}\n\n" => ".global_side .medborder_detailhead_wrap {\n\tpadding: 0;\n}\n\n.global_side .medborder_detailhead {\n\tborder-bottom: 0;\n\tpadding-left: 0;\n\tpadding-top: 5px;\n}\n\n", "\ttop: -256000px;\n\tleft: 0;\n" => "\tdisplay: block; /* stops browser bugs where it interacts with the layout flow incorrectly */\n", ".page_icon {\n\tvertical-align: middle;\n\t{+START,IF,{\$MOBILE}}\n\t\tmargin-bottom: 5px;\n\t{+END}\n}\n\n" => ".standardbox_title_classic .page_icon {\n\tmargin: -1px 3px 0 0;\n}\n\n", ".input_huge_field {\n}\n\n" => ".password_strength {\n\tfloat: right;\n\twidth: 100px;\n\tborder: 1px solid #6b81a1; /* {\$,wizard, 100% medborder.border} */\n\tdisplay: none;\n}\n\n.password_strength_inner {\n\theight: 1em;\n\twidth: 0px;\n}\n\n", ".radio_list_picture {\n\tfloat: {!en_left};\n\twhite-space: nowrap;\n\tpadding: 3px;\n\tmin-width: 40px;\n\tmin-height: 40px;\n}\n\n" => "#page_running_admin_themes .radio_list_picture {\n\tfloat: none;\n\tmargin: 15px;\n\tborder: 1px solid #c1cee3; /* {\$,wizard, 100% lightborder} */\n}\n\n.radio_list_picture img {\n\tmax-width: 100px;\n}\n\n", ".tab_last {\n\tborder-right: 1px solid;\n\tborder-color: #b5b5b5; /* {\$,wizard, 100% b5b5b5} */\n}\n\n" => ".tab_surround .tab { /* subtabs */\n\tpadding-top: 5px !important;\n\theight: 18px;\n\tfont-size: 0.88em;\n}\n\n", "#screen_actions .digg {\n\tbackground-image: url('{\$IMG,recommend/digg}');\n}" => "\n#screen_actions .google_plusone {\n\tmargin-top: 1px;\n}\n")); $css_file_append = array('galleries.css' => array("\n/* Miscellaneous media handling */\n\n.gallery_pdf {\n\twidth: 100%;\n\theight: 600px;\n}"), 'no_cache.css' => array("\n{\$BROWSER,opera,,tt\\, kbd\\, samp \\{ font-size: 1.25em; \\}}\n")); // NB: This UNIX command can work out what theme images are added... // OLD=/Library/WebServer/Documents/test/themes/default/images ; NEW=/Library/WebServer/Documents/git/themes/default/images ; diff -r $OLD $NEW | grep "Only in $NEW" | grep -v .DS_Store | sed "s#Only in "$NEW"##g" | sed "s#: #/#g" | sed "s#^/##g" | sed "s#^EN/##g" | sed "s#\.*$##" // Obviously only theme-wizable images should go here $theme_images_new = array('page/add_ticket', 'page/disable_notifications', 'page/enable_notifications', 'page/forum', 'page/send_message', 'pageitem/disable_notifications', 'pageitem/enable_notifications', 'pageitem/reply', 'pageitem/send_message'); $theme_images_renames = array('standardboxes/title_gradiant' => 'standardboxes/title_gradient', 'quote_gradiant' => 'quote_gradient', 'zone_gradiant' => 'zone_gradient'); $templates_replace = array('*' => array('_true' => '1', '_false' => '0', 'TOPIC_NAME' => 'TOPIC_TITLE', 'load_XML_doc' => 'do_ajax_request', 'DESPATCH' => 'DISPATCH')); /*Find deleted/renamed templates: OLD=/Library/WebServer/Documents/test/themes/default/templates ; NEW=/Library/WebServer/Documents/git/themes/default/templates ; diff -r $OLD $NEW | grep .tpl$ | grep "Only in "$OLD | sed "s#Only in "$OLD": ##"*/ $templates_rename = array('COMMENTS.tpl' => 'COMMENTS_POSTING_FORM.tpl', 'CEDI_RATING_INSIDE.tpl' => 'CEDI_RATING_FORM.tpl', 'RATING_INSIDE.tpl' => 'RATING_FORM.tpl', 'RATING.tpl' => 'RATING_BOX.tpl', 'RATING_INLINE.tpl' => 'RATING_INLINE_STATIC.tpl'); /*Find diff of changes templates OLD=/Library/WebServer/Documents/test/themes/default/templates ; NEW=/Library/WebServer/Documents/git/themes/default/templates ; diff -u $OLD $NEW > ~/Desktop/diff.txt*/ $templates_borked = array('COMMENTS_POSTING_FORM.tpl', 'CEDI_RATING_FORM.tpl', 'RATING_FORM.tpl', 'RATING_BOX.tpl', 'RATING_INLINE_STATIC.tpl', 'COMMENTS_WRAPPER.tpl', 'CEDI_RATING.tpl', 'OCF_MEMBER_PROFILE_SCREEN.tpl', 'ATTACHMENT.tpl', 'POSTING_FORM.tpl', 'POSTING_FIELD.tpl', 'ATTACHMENTS.tpl', 'BLOCK_HELPER_DONE.tpl', 'ATTACHMENT_IMG.tpl', 'ATTACHMENT_IMG_MINI.tpl', 'CATALOGUE_DEFAULT_CATEGORY_SCREEN.tpl', 'JAVASCRIPT.tpl', 'JAVASCRIPT_AJAX.tpl', 'JAVASCRIPT_AJAX_PEOPLE_LISTS.tpl', 'JAVASCRIPT_CHAT.tpl', 'JAVASCRIPT_DATE_CHOOSER.tpl', 'JAVASCRIPT_EDITING.tpl', 'JAVASCRIPT_JWPLAYER.tpl', 'JAVASCRIPT_MENU_EDITOR.tpl', 'JAVASCRIPT_PERMISSIONS.tpl', 'JAVASCRIPT_POSTING.tpl', 'JAVASCRIPT_SOUND.tpl', 'JAVASCRIPT_STAFF.tpl', 'JAVASCRIPT_SWFUPLOAD.tpl', 'JAVASCRIPT_THUMBNAILS.tpl', 'JAVASCRIPT_TREE_LIST.tpl', 'JAVASCRIPT_VALIDATION.tpl', 'JAVASCRIPT_YAHOO_EVENTS.tpl', 'JAVASCRIPT_ZONE_EDITOR.tpl', 'FORM_SCREEN_INPUT_CAPTCHA.tpl', 'FORM_SCREEN_INPUT_DATE.tpl', 'FORM_SCREEN_INPUT_PASSWORD.tpl', 'FORM_SCREEN_INPUT_RADIO_LIST.tpl', 'FORM_SCREEN_INPUT_RADIO_LIST_ENTRY_PICTURE_2.tpl', 'FORM_SCREEN_INPUT_TICK.tpl', 'FORM_SCREEN_INPUT_TREE_LIST.tpl', 'FORM_SCREEN_INPUT_UPLOAD.tpl', 'FORM_SCREEN_INPUT_UPLOAD_MULTI.tpl', 'GALLERY_NAV.tpl', 'MENU_EDITOR_BRANCH_WRAP.tpl', 'MENU_EDITOR_SCREEN.tpl', 'OCF_FORUM.tpl', 'OCF_MEMBER_BAR.tpl', 'OCF_TOPIC_WRAP.tpl', 'PAGE_LINK_CHOOSER.tpl', 'POINTS_SCREEN.tpl', 'SUPPORT_TICKETS_SCREEN.tpl', 'SUPPORT_TICKET_SCREEN.tpl'); } else { $errors[] = do_lang_tempcode('NO_DEFINED_THEME_UPGRADER'); return array($errors, array()); } if (addon_installed('themewizard')) { require_code('themewizard'); $seed = find_theme_seed($theme); $dark = find_theme_dark($theme); list($colours, $landscape) = calculate_theme($seed, 'default', 'equations', 'colours', $dark); } // CSS $css_dir = get_custom_file_base() . '/themes/' . filter_naughty($theme) . '/css_custom/'; $dh = @opendir($css_dir); if ($dh !== false) { while (($css_file = readdir($dh)) !== false) { if (substr($css_file, -4) != '.css') { continue; } if (substr($css_file, 0, 1) == '.') { continue; } $css_file_contents = file_get_contents($css_dir . $css_file); $orig_css_file_contents = $css_file_contents; if (strpos($css_file_contents, $css_recognition_string) === false) { $errors[] = do_lang_tempcode('NON_RECOGNISED_CSS_FILE', escape_html($css_file), escape_html(float_to_raw_string($from_version))); //continue; Actually we'll let it pass } // Apply single match rules. First check single match rules apply exactly once (means rule is bogus if it matches more than once, or unusable if not at all) foreach (array('css_replace' => $css_replace__single_match, 'css_prepend' => $css_prepend__single_match, 'css_append' => $css_append__single_match) as $rule_set_type => $rule_set) { foreach ($rule_set as $target_file => $_rule_set) { // If people have moved CSS into global.css, to optimise page load times if ($target_file != '*' && $target_file != 'global.css' && $css_file == 'global.css') { if (file_exists($css_dir . $target_file) && strlen(trim(file_get_contents($css_dir . $target_file))) == 0) { $target_file = 'global.css'; } } if ($target_file == '*' || $target_file == $css_file) { foreach ($_rule_set as $from => $to) { // Apply theme wizard to $to if (addon_installed('themewizard')) { $to = theme_wizard_colours_to_css($to, $landscape, 'default', 'equations', $seed); } $occurrences = substr_count($css_file_contents, $from); if ($occurrences == 0) { if (addon_installed('themewizard')) { $from = theme_wizard_colours_to_css($from, $landscape, 'default', 'equations', $seed); $occurrences = substr_count($css_file_contents, $from); } } if ($occurrences == 0) { $errors[] = do_lang_tempcode('CSS_RULE_UNMATCHED_' . $rule_set_type, escape_html($from), escape_html($to), escape_html($target_file)); } elseif ($occurrences > 1) { $errors[] = do_lang_tempcode('CSS_RULE_OVERMATCHED_' . $rule_set_type, escape_html($from), escape_html($to), escape_html($target_file)); } else { switch ($rule_set_type) { case 'css_replace': $css_file_contents = str_replace($from, $to, $css_file_contents); break; case 'css_prepend': $pos = strpos($css_file_contents, $from); if (substr($css_file_contents, $pos - strlen($to), strlen($to)) != $to) { $css_file_contents = substr($css_file_contents, 0, $pos) . $to . substr($css_file_contents, $pos); } break; case 'css_append': $pos = strpos($css_file_contents, $from) + strlen($from); if (substr($css_file_contents, $pos, strlen($to)) != $to) { $css_file_contents = substr($css_file_contents, 0, $pos) . $to . substr($css_file_contents, $pos); } break; } } } } } } // Apply multi-match rules foreach (array('css_replace' => $css_replace__multi_match, 'css_prepend' => $css_prepend__multi_match, 'css_append' => $css_append__multi_match) as $rule_set_type => $rule_set) { foreach ($rule_set as $target_file => $_rule_set) { if ($target_file == '*' || $target_file == $css_file) { foreach ($_rule_set as $from_a => $to) { // Apply theme wizard to $to if (addon_installed('themewizard')) { $to = theme_wizard_colours_to_css($to, $landscape, 'default', 'equations', $seed); } $froms = array($from_a); if (addon_installed('themewizard')) { $froms[] = theme_wizard_colours_to_css($from_a, $landscape, 'default', 'equations', $seed); } foreach ($froms as $from) { switch ($rule_set_type) { case 'css_replace': $css_file_contents = str_replace($from, $to, $css_file_contents); break; case 'css_prepend': $pos = 0; do { $pos = strpos($css_file_contents, $from, $pos); if ($pos !== false) { if (substr($css_file_contents, $pos, -strlen($to)) != $to) { $css_file_contents = substr($css_file_contents, 0, $pos) . $to . substr($css_file_contents, $pos); $pos += strlen($to) + strlen($from); } else { $pos += strlen($from); } } } while ($pos !== false); break; case 'css_append': $pos = 0; do { $pos = strpos($css_file_contents, $from, $pos); if ($pos !== false) { if (substr($css_file_contents, $pos, strlen($to)) != $to) { $pos += strlen($from); $css_file_contents = substr($css_file_contents, 0, $pos) . $to . substr($css_file_contents, $pos); $pos += strlen($to); } else { $pos += strlen($from); } } } while ($pos !== false); break; } } } } } } // Apply unmatched rules foreach ($css_file_append as $target_file => $rule_set) { if ($target_file == '*' || $target_file == $css_file) { foreach ($rule_set as $to) { $css_file_contents .= $to; } } } if (!$test_run) { // Take revision $revision_file = $css_dir . $css_file . '.' . strval(time()); if (@copy($css_dir . $css_file, $revision_file) !== false) { fix_permissions($revision_file); sync_file($revision_file); } // Save if ($orig_css_file_contents != $css_file_contents) { $outfile = @fopen($css_dir . $css_file, 'wb') or intelligent_write_error($css_dir . $css_file); fwrite($outfile, $css_file_contents); fclose($outfile); } $successes[] = do_lang_tempcode('CSS_FILE_UPGRADED', escape_html($css_file)); } } closedir($dh); } // Theme images require_code('themes2'); $langs = array('EN' => 'lang'); //find_all_langs(); foreach ($theme_images_renames as $old => $new) { foreach (array_keys($langs) as $lang) { $path = urldecode(find_theme_image($old, true, true, $theme, $lang)); if ($path != '') { $new_path = str_replace('/' . $old, '/' . $new, $path); if (!$test_run) { if (!file_exists(get_custom_file_base() . '/' . $new_path)) { if (file_exists($path)) { afm_move($path, $new_path); } $where_map = array('theme' => $theme, 'id' => $new); if ($lang != '' && !is_null($lang)) { $where_map['lang'] = $lang; } $GLOBALS['SITE_DB']->query_delete('theme_images', $where_map); actual_edit_theme_image($old, $theme, $lang, $new, $new_path); $successes[] = do_lang_tempcode('THEME_IMAGE_RENAMED', escape_html($old), escape_html($new)); } } } } } if (addon_installed('themewizard')) { if ($theme != 'default') { foreach ($theme_images_new as $new) { foreach (array_keys($langs) as $lang) { $path = urldecode(find_theme_image($new, true, true, 'default', $lang)); if ($path != '') { $new_path = str_replace('themes/default/images/', 'themes/' . $theme . '/images/', $path); if (!file_exists(get_custom_file_base() . '/' . $new_path)) { if (!$test_run) { afm_make_directory(dirname($new_path), true, true); } $image = calculate_theme($seed, 'default', 'equations', $new, $dark, $colours, $landscape, $lang); if (!is_null($image)) { if (!$test_run) { @imagepng($image, get_custom_file_base() . '/' . $new_path) or intelligent_write_error(get_custom_file_base() . '/' . $new_path); imagedestroy($image); fix_permissions(get_custom_file_base() . '/' . $new_path); sync_file(get_custom_file_base() . '/' . $new_path); $successes[] = do_lang_tempcode('THEME_IMAGE_NEW', escape_html($new)); } } } } } } } } // Templates $templates_dir = get_custom_file_base() . '/themes/' . filter_naughty($theme) . '/templates_custom/'; $dh = @opendir($templates_dir); if ($dh !== false) { while (($templates_file = readdir($dh)) !== false) { if (substr($templates_file, -4) != '.tpl') { continue; } $templates_file_contents = file_get_contents($templates_dir . $templates_file); $orig_templates_file_contents = $templates_file_contents; foreach ($templates_replace as $target_file => $rule_set) { if ($target_file == '*' || $target_file == $templates_file) { foreach ($rule_set as $from => $to) { $templates_file_contents = str_replace($from, $to, $templates_file_contents); } } } if (array_key_exists($templates_file, $templates_rename)) { if (!$test_run) { @rename($templates_dir . $templates_file, $templates_dir . $templates_rename[$templates_file]) or intelligent_write_error($templates_dir . $templates_rename[$templates_file]); $successes[] = do_lang_tempcode('TEMPLATE_RENAMED', escape_html($templates_file), escape_html($templates_rename[$templates_file])); } $templates_file = $templates_rename[$templates_file]; } if ($templates_file_contents != $orig_templates_file_contents) { if (!$test_run) { $successes[] = do_lang_tempcode('TEMPLATE_ALTERED', escape_html($templates_file)); // Save $outfile = @fopen($templates_dir . $templates_file, 'wb') or intelligent_write_error($templates_dir . $templates_file); fwrite($outfile, $templates_file_contents); fclose($outfile); } } if (in_array($templates_file, $templates_borked)) { $errors[] = do_lang_tempcode('TEMPLATE_WILL_NEED_RESTORING', escape_html($templates_file)); } } closedir($dh); } return array($errors, $successes); }
/** * UI for a setup wizard step (theme). * * @return tempcode The UI */ function step8() { $title = get_page_title('SETUP_WIZARD_STEP', true, array(integer_format(8), integer_format(10))); require_lang('themes'); require_code('themewizard'); $post_url = build_url(array('page' => '_SELF', 'type' => 'step9'), '_SELF'); $text = do_lang_tempcode('SETUP_WIZARD_8_DESCRIBE'); $submit_name = do_lang_tempcode('PROCEED'); require_code('form_templates'); $fields = new ocp_tempcode(); $fields->attach(form_input_colour(do_lang_tempcode('SEED_COLOUR'), do_lang_tempcode('DESCRIPTION_SEED_COLOUR'), 'seed_hex', '#' . find_theme_seed('default'), true)); $fields->attach(form_input_tick(do_lang_tempcode('DARK_THEME'), do_lang_tempcode('DESCRIPTION_DARK_THEME'), 'dark', get_param_integer('dark', 0) == 1)); //breadcrumb_set_parents(array(array('_SELF:_SELF:misc',do_lang_tempcode('START')))); return do_template('FORM_SCREEN', array('_GUID' => '7ef31eb9712cff98da57a92fc173f7af', 'PREVIEW' => true, 'SKIP_VALIDATION' => true, 'TITLE' => $title, 'SKIPPABLE' => 'skip_8', 'FIELDS' => $fields, 'URL' => $post_url, 'TEXT' => $text, 'SUBMIT_NAME' => $submit_name, 'HIDDEN' => static_evaluate_tempcode(build_keep_post_fields()))); }