function sp_barebones_options_save_custom()
{
    if (isset($_POST['commit-reset'])) {
        include_once SPBBADMIN . 'sp-barebones-activate.php';
        sp_barebones_setup(false);
        $msg = spa_text('Settings returned to default');
    }
    if (isset($_POST['commit-save']) || isset($_POST['commit-test'])) {
        $files = array();
        if (isset($_POST['commit-save'])) {
            $files[] = SF_STORE_DIR . '/' . 'sp-custom-settings/sp-barebones-custom-settings.php';
            $files[] = SF_STORE_DIR . '/' . 'sp-custom-settings/sp-barebones-test-settings.php';
            $msg = spa_text('Site custom settings updated');
        } else {
            $files[] = SF_STORE_DIR . '/' . 'sp-custom-settings/sp-barebones-test-settings.php';
            $msg = spa_text('Test custom settings updated');
        }
        foreach ($files as $file) {
            $C1 = empty($_POST['C1']) ? '#' : $_POST['C1'];
            $C2 = empty($_POST['C2']) ? '#' : $_POST['C2'];
            $C3 = empty($_POST['C3']) ? '#' : $_POST['C3'];
            $C4 = empty($_POST['C4']) ? '#' : $_POST['C4'];
            $C5 = empty($_POST['C5']) ? '#' : $_POST['C5'];
            $C6 = empty($_POST['C6']) ? '#' : $_POST['C6'];
            $C7 = empty($_POST['C7']) ? '#' : $_POST['C7'];
            $C8 = empty($_POST['C8']) ? '#' : $_POST['C8'];
            $C9 = empty($_POST['C9']) ? '#' : $_POST['C9'];
            $C10 = empty($_POST['C10']) ? '#' : $_POST['C10'];
            $C11 = empty($_POST['C11']) ? '#' : $_POST['C11'];
            $FN = empty($_POST['FN']) ? 'Tahoma' : $_POST['FN'];
            $F1 = empty($_POST['F1']) ? '100' : $_POST['F1'];
            if (is_writeable($file)) {
                $ops = "<?php\n";
                $ops .= "\$ops = array(\n";
                $ops .= "'C1' => '" . $C1 . "',\n";
                $ops .= "'C2' => '" . $C2 . "',\n";
                $ops .= "'C3' => '" . $C3 . "',\n";
                $ops .= "'C4' => '" . $C4 . "',\n";
                $ops .= "'C5' => '" . $C5 . "',\n";
                $ops .= "'C6' => '" . $C6 . "',\n";
                $ops .= "'C7' => '" . $C7 . "',\n";
                $ops .= "'C8' => '" . $C8 . "',\n";
                $ops .= "'C9' => '" . $C9 . "',\n";
                $ops .= "'C10' => '" . $C10 . "',\n";
                $ops .= "'C11' => '" . $C11 . "',\n";
                $ops .= "'FN' => '" . $FN . "',\n";
                $ops .= "'F1' => '" . $F1 . "',\n";
                $ops .= ");\n?>";
                $f = fopen($file, 'w');
                if ($f !== false) {
                    fwrite($f, $ops);
                    fclose($f);
                } else {
                    $msg = spa_text('Unable to save theme file');
                }
            } else {
                $msg = spa_text('Theme file is not writable!');
            }
        }
    }
    # need to clear combined css cache for changes to take effect
    sp_clear_combined_css('all');
    sp_clear_combined_css('mobile');
    sp_clear_combined_css('tablet');
    echo $msg;
}
function sp_barebones_options_form()
{
    if (!sp_current_user_can('SPF Manage Themes')) {
        spa_etext('Access denied - you do not have permission');
        die;
    }
    include_once SPBBADMIN . 'sp-barebones-activate.php';
    sp_barebones_setup(true);
    ?>

<style type="text/css">
	.color-picker { height: 50px; }
</style>

<script type="text/javascript">
	jQuery(document).ready(function($) {
		var colorPickers = $('.color-picker');
		for (e in colorPickers) {
			if (colorPickers[e].id != undefined) {
				var colorPickerID = colorPickers[e].id;
				$('#' + colorPickerID + '-color').farbtastic('#' + colorPickerID);
			}
		}

		$('.fabox').hide();

		$('.color-picker').click(function() {
			$(this).parent().find('.fabox').fadeIn();
		});

		$(document).mousedown(function() {
			$('.fabox').each(function() {
				var display = $(this).css('display');
				if (display == 'block') $(this).fadeOut();
			});
		});
	});

	function spjLoadTestView(url, title) {
		var aWidth = (window.innerWidth-80);
		var aHeight = (window.innerHeight-80);
		spjDialogAjax(this, url, title, aWidth, aHeight, 'center');
	}
</script>

<?php 
    include_once SF_STORE_DIR . '/' . 'sp-custom-settings/sp-barebones-test-settings.php';
    spa_paint_options_init();
    spa_paint_open_tab(__('Barebones Custom Theme Settings', 'spBarebones'), true);
    echo '<br /><div class="sfoptionerror" style="font-size: 13px;">';
    $url = SFHOMEURL . "index.php?sp_ahah=help&amp;file=admin-themes&amp;item=custom-options&amp;sfnonce=" . wp_create_nonce('forum-ahah');
    echo "<input type='button' value='Help' class='button-primary' style='float:right;' onclick='spjDialogAjax(this, \"{$url}\", \"Simple:Press Help\", 600, 0, 0);' />";
    echo "<span style='font-weight:bold';'>";
    spa_etext('Before using this customiser we strongly recommend you click on the help button and familiarise yourself with how it works to avoid inadvertently altering your live forum display');
    echo "</span>";
    echo '.<br />';
    echo '</div>';
    echo "</div>";
    echo '<div class="sp-half-form">';
    spa_paint_open_panel();
    spa_paint_open_fieldset('', false, '', false);
    ?>
			<div>
				<div style="width: 49.5%; float:left;">
					<p>Standard and general unlinked text</p>
					<input id="C1" class="color-picker" type="text" value="<?php 
    echo $ops['C1'];
    ?>
" name="C1" style="width:60%;font-weight:bold;float:left;" />
					<div class="clearleft"></div>
					<div id="C1-color" class="fabox" style="margin: 0px auto; width: 195px; float:left;"></div>
					<div class="clearboth"></div>
				</div>
			</div>
<?php 
    spa_paint_close_fieldset();
    spa_paint_close_panel();
    spa_paint_open_panel();
    spa_paint_open_fieldset('', false, '', false);
    ?>
			<div>
				<div style="width: 49.5%; float:left;">
					<p>Main Headings and<br />Footer Background</p>
					<input id="C3" class="color-picker" type="text" value="<?php 
    echo $ops['C3'];
    ?>
" name="C3" style="width:60%;font-weight:bold;float:left;" />
					<div class="clearleft"></div>
					<div id="C3-color" class="fabox" style="margin: 0px auto; width: 195px; float:left;"></div>
				</div>

				<div style="width: 49.5%; float:left;">
					<p>Title rows in<br />index listings</p>
					<input id="C4" class="color-picker" type="text" value="<?php 
    echo $ops['C4'];
    ?>
" name="C4" style="width:60%;font-weight:bold;float:left;" />
					<div class="clearleft"></div>
					<div id="C4-color" class="fabox" style="margin: 0px auto; width: 195px; float:left;"></div>
				</div>
				<div class="clearboth"></div><hr>
			</div>

			<div>
				<div style="width: 49.5%; float:left;">
					<p>Background of odd rows<br />in index listings</p>
					<input id="C2" class="color-picker" type="text" value="<?php 
    echo $ops['C2'];
    ?>
" name="C2" style="width:60%;font-weight:bold;float:left;" />
					<div class="clearleft"></div>
					<div id="C2-color" class="fabox" style="margin: 0px auto; width: 195px; float:left;"></div>
				</div>

				<div style="width: 49.5%; float:right;">
					<p>Background of even rows<br />in index listings</p>
					<input id="C6" class="color-picker" type="text" value="<?php 
    echo $ops['C6'];
    ?>
" name="C6" style="width:60%;font-weight:bold;float:left;" />
					<div class="clearleft"></div>
					<div id="C6-color" class="fabox" style="margin: 0px auto; width: 195px; float:left;"></div>
				</div>
				<div class="clearboth"></div>
			</div>
<?php 
    spa_paint_close_fieldset();
    spa_paint_close_panel();
    spa_paint_open_panel();
    spa_paint_open_fieldset('', false, '', false);
    spa_paint_input(__('Font Family(s) in CSS format', 'spBarebones'), 'FN', $ops['FN']);
    spa_paint_input(__('Base Font Size (as percentage value)', 'spBarebones'), 'F1', $ops['F1']);
    spa_paint_close_fieldset();
    spa_paint_close_panel();
    spa_paint_tab_right_cell();
    spa_paint_open_panel();
    spa_paint_open_fieldset('', false, '', false);
    ?>
			<div>
				<div style="width: 49.5%; float:left;">
					<p>Icon Glyphs</p>
					<input id="C7" class="color-picker" type="text" value="<?php 
    echo $ops['C7'];
    ?>
" name="C7" style="width:60%;font-weight:bold; float:left;" />
					<div class="clearleft"></div>
					<div id="C7-color" class="fabox" style="margin: 0px auto; width: 195px; float:left;"></div>
				</div>

				<div style="width: 49.5%; float:right;">
					<p>Icon Glyphs Hover</p>
					<input id="C8" class="color-picker" type="text" value="<?php 
    echo $ops['C8'];
    ?>
" name="C8" style="width:60%;font-weight:bold; float:left;" />
					<div class="clearleft"></div>
					<div id="C8-color" class="fabox" style="margin: 0px auto; width: 195px; float:left;"></div>
				</div>
				<div class="clearboth"></div>
			</div>
<?php 
    spa_paint_close_fieldset();
    spa_paint_close_panel();
    spa_paint_open_panel();
    spa_paint_open_fieldset('', false, '', false);
    ?>
			<div>
				<div style="width: 49.5%; float:left;">
					<p>Primary <br />Link text labels</p>
					<input id="C5" class="color-picker" type="text" value="<?php 
    echo $ops['C5'];
    ?>
" name="C5" style="width:60%;font-weight:bold;float:left;" />
					<div class="clearleft"></div>
					<div id="C5-color" class="fabox" style="margin: 0px auto; width: 195px; float:left;"></div>
				</div>
				<div style="width: 49.5%; float:left;">
					<p>Primary <br />Link text hover</p>
					<input id="C9" class="color-picker" type="text" value="<?php 
    echo $ops['C9'];
    ?>
" name="C9" style="width:60%;font-weight:bold;float:left;" />
					<div class="clearleft"></div>
					<div id="C9-color" class="fabox" style="margin: 0px auto; width: 195px; float:left;"></div>
				</div>
				<div class="clearboth"></div><hr>
			</div>

			<div>
				<div style="width: 49.5%; float:left;">
					<p>Secondary <br />Link text labels</p>
					<input id="C10" class="color-picker" type="text" value="<?php 
    echo $ops['C10'];
    ?>
" name="C10" style="width:60%;font-weight:bold;float:left;" />
					<div class="clearleft"></div>
					<div id="C10-color" class="fabox" style="margin: 0px auto; width: 195px; float:left;"></div>
				</div>
				<div style="width: 49.5%; float:left;">
					<p>Secondary <br />Link text hover</p>
					<input id="C11" class="color-picker" type="text" value="<?php 
    echo $ops['C11'];
    ?>
" name="C11" style="width:60%;font-weight:bold;float:left;" />
					<div class="clearleft"></div>
					<div id="C11-color" class="fabox" style="margin: 0px auto; width: 195px; float:left;"></div>
				</div>
				<div class="clearboth"></div>
			</div>
<?php 
    spa_paint_close_fieldset();
    spa_paint_close_panel();
    spa_paint_close_container();
}
Exemplo n.º 3
0
function sp_barebones_activate()
{
    include_once SPBBADMIN . 'sp-barebones-activate.php';
    sp_barebones_setup();
}