<commit_before><?
defined('C5_EXECUTE') or die("Access Denied.");
if (ENABLE_CUSTOM_DESIGN == false) {
	die(t('Custom design options have been disabled.'));
}

global $c;

$txt = Loader::helper('text');
$form = Loader::helper('form');
$fh = Loader::helper('form/color'); 
$ah = Loader::helper("concrete/asset_library");

if (isset($_REQUEST['cspID']) && $_REQUEST['cspID'] > 0) {
	$csp = CustomStylePreset::getByID($_REQUEST['cspID']);
	if (is_object($csp)) {
		$style = $csp->getCustomStylePresetRuleObject();
	}
} else if (is_object($style)) {
	$selectedCsrID = $style->getCustomStyleRuleID();
}

if(!$style) $style = new CustomStyleRule();

$cssData = $style->getCustomStyleRuleCustomStylesArray();

$presets = CustomStylePreset::getList();
$presetsArray = array();
foreach($presets as $csp) {
	$presetsArray[$csp->getCustomStylePresetID()] = $csp->getCustomStylePresetName();
}

$presetsArray[0] = t('** Custom (No Preset)');

if (!isset($_REQUEST['csrID'])) {
	$cspID = $style->getCustomStylePresetID();
}

if ($_REQUEST['subtask'] == 'delete_custom_style_preset') {
	$cspID = 0;
}
?>

<? if (!$_REQUEST['refresh']) { ?>
	<div class="ccm-ui" id="ccm-custom-style-wrapper">
<? } ?>

<form class="form-stacked" method="post" id="ccmCustomCssForm" action="<?=$action?>" style="width:96%; margin:auto;">

	<input id="ccm-reset-style" name="reset_css" type="hidden" value="0" />
	
	<? if (count($presets) > 0) { ?>
		<h3><?=t('Saved Presets')?></h3>
	
		<?=$form->select('cspID', $presetsArray, $cspID, array('style' => 'vertical-align: middle'))?>
		<a href="javascript:void(0)" id="ccm-style-delete-preset" style="display: none" onclick="ccmCustomStyle.deletePreset()"><img src="<?=ASSETS_URL_IMAGES?>/icons/delete_small.png" style="vertical-align: middle" width="16" height="16" border="0" /></a>
		
		<br/><br/>
		
		<input type="hidden" id="ccm-custom-style-refresh-action" value="<?=$refreshAction?>" /> 
	<? } ?>
	
	<input type="hidden" name="selectedCsrID" value="<?=$selectedCsrID?>" />
	<ul id="ccm-styleEditPane-tabs" class="ccm-dialog-tabs" style="margin-left:0px">
		<li class="ccm-nav-active"><a id="ccm-styleEditPane-tab-fonts" href="#" onclick="return ccmCustomStyle.tabs(this,'fonts');"><?=t('Fonts') ?></a></li>
		<li><a href="javascript:void(0);" onclick="return ccmCustomStyle.tabs(this,'background');"><?=t('Background') ?></a></li>
		<li><a href="javascript:void(0);" onclick="return ccmCustomStyle.tabs(this,'border');"><?=t('Border') ?></a></li>
		<li><a href="javascript:void(0);" onclick="return ccmCustomStyle.tabs(this,'spacing');"><?=t('Spacing') ?></a></li>
		<li><a href="javascript:void(0);" onclick="return ccmCustomStyle.tabs(this,'css');"><?=t('CSS')?></a></li> 
	</ul>		
	
	<div id="ccmCustomCssFormTabs">
	
		<?php Loader::element('custom_style/fonts', array('cssData' => $cssData, 'fh' => $fh));?>
	
		<?php Loader::element('custom_style/background', array('cssData' => $cssData, 'fh' => $fh, 'ah' => $ah));?>
	
		<?php Loader::element('custom_style/border', array('cssData' => $cssData, 'fh' => $fh));?>

		<?php Loader::element('custom_style/spacing', array('cssData' => $cssData, 'fh' => $fh));?>
		
		<?php Loader::element('custom_style/css', array('style' => $style));?>

	</div>
	
	<br/>
	
	<? if ($cspID > 0) { 
		$cspx = CustomStylePreset::getByID($cspID);?>
		<div id="cspFooterPreset" style="display: none">
			<div class="ccm-note-important">
				<h2><?=t('You are changing a preset')?></h2>
				<div><?=$form->radio('cspPresetAction', 'update_existing_preset', true)?> <?=t('Update "%s" preset everywhere it is used', $cspx->getCustomStylePresetName())?></div>
				<div><?=$form->radio('cspPresetAction', 'save_as_custom_style')?> <?=t('Use this style here, and leave "%s" unchanged', $cspx->getCustomStylePresetName())?></div>
				<div><?=$form->radio('cspPresetAction', 'create_new_preset')?> <?=t('Save this style as a new preset')?><br/><span style="margin-left: 20px"><?=$form->text('cspName', array('style' => 'width:  127px', 'disabled' => true))?></span></div>
			</div>
		</div>
	<? } ?>
	
	<div id="cspFooterNoPreset" >
		<?=$form->checkbox('cspPresetAction', 'create_new_preset')?>
		<?=t('Save this style as a new preset.')?>
		<span style="margin-left: 10px">
			<?=$form->text('cspName', array('style' => 'width:  140px', 'disabled' => true))?>
		</span>
	</div>
	
	<br/>
	
	<div class="dialog-buttons">
		<a href="#" class="ccm-button-left cancel btn" onclick="jQuery.fn.dialog.closeTop(); return false"><?=t('Cancel')?></a>
	
		<a href="javascript:void(0)" onclick="$('#ccmCustomCssForm').submit()" class="btn primary ccm-button-right accept"><span><?=t('Save')?></span></a>
		<? if ($cspID < 1) { ?>
			<a onclick="return ccmCustomStyle.resetAll();" id="ccm-reset-style-button" class="btn ccm-button-right accept" style="margin-right:8px; "><span><?=t('Reset Styles')?></span></a>
		<? } ?>
	</div>
	
	<div class="ccm-spacer"></div> 
	
	<div class="ccm-note" style="margin-top:16px;">
		<?=t('Note: Styles set here are often overridden by those defined within the various block types.')?>
	</div>		
	
<?
$valt = Loader::helper('validation/token');
$valt->output();
?>
</form>

<script type="text/javascript">
	$(function() {
		ccmCustomStyle.initForm();
	});
</script>

<? if (!$_REQUEST['refresh']) { ?>
	</div>
<? } ?><commit_msg>Fix Block Design Preset & Footer Buttons<commit_after><?
defined('C5_EXECUTE') or die("Access Denied.");
if (ENABLE_CUSTOM_DESIGN == false) {
	die(t('Custom design options have been disabled.'));
}

global $c;

$txt = Loader::helper('text');
$form = Loader::helper('form');
$fh = Loader::helper('form/color'); 
$ah = Loader::helper("concrete/asset_library");

if (isset($_REQUEST['cspID']) && $_REQUEST['cspID'] > 0) {
	$csp = CustomStylePreset::getByID($_REQUEST['cspID']);
	if (is_object($csp)) {
		$style = $csp->getCustomStylePresetRuleObject();
	}
} else if (is_object($style)) {
	$selectedCsrID = $style->getCustomStyleRuleID();
}

if(!$style) $style = new CustomStyleRule();

$cssData = $style->getCustomStyleRuleCustomStylesArray();

$presets = CustomStylePreset::getList();
$presetsArray = array();
foreach($presets as $csp) {
	$presetsArray[$csp->getCustomStylePresetID()] = $csp->getCustomStylePresetName();
}

$presetsArray[0] = t('** Custom (No Preset)');
ksort($presetsArray);

if (!isset($_REQUEST['csrID'])) {
	$cspID = $style->getCustomStylePresetID();
}

if ($_REQUEST['subtask'] == 'delete_custom_style_preset') {
	$cspID = 0;
}
?>

<? if (!$_REQUEST['refresh']) { ?>
	<div class="ccm-ui" id="ccm-custom-style-wrapper">
<? } ?>

<form class="form-stacked" method="post" id="ccmCustomCssForm" action="<?=$action?>" style="width:96%; margin:auto;">

	<input id="ccm-reset-style" name="reset_css" type="hidden" value="0" />
	
	<? if (count($presets) > 0) { ?>
		<h3><?=t('Saved Presets')?></h3>
	
		<?=$form->select('cspID', $presetsArray, $cspID, array('style' => 'vertical-align: middle'))?>
		<a href="javascript:void(0)" id="ccm-style-delete-preset" style="display: none" onclick="ccmCustomStyle.deletePreset()"><img src="<?=ASSETS_URL_IMAGES?>/icons/delete_small.png" style="vertical-align: middle" width="16" height="16" border="0" /></a>
		
		<br/><br/>
		
		<input type="hidden" id="ccm-custom-style-refresh-action" value="<?=$refreshAction?>" /> 
	<? } ?>
	
	<input type="hidden" name="selectedCsrID" value="<?=$selectedCsrID?>" />
	<ul id="ccm-styleEditPane-tabs" class="ccm-dialog-tabs" style="margin-left:0px">
		<li class="ccm-nav-active"><a id="ccm-styleEditPane-tab-fonts" href="#" onclick="return ccmCustomStyle.tabs(this,'fonts');"><?=t('Fonts') ?></a></li>
		<li><a href="javascript:void(0);" onclick="return ccmCustomStyle.tabs(this,'background');"><?=t('Background') ?></a></li>
		<li><a href="javascript:void(0);" onclick="return ccmCustomStyle.tabs(this,'border');"><?=t('Border') ?></a></li>
		<li><a href="javascript:void(0);" onclick="return ccmCustomStyle.tabs(this,'spacing');"><?=t('Spacing') ?></a></li>
		<li><a href="javascript:void(0);" onclick="return ccmCustomStyle.tabs(this,'css');"><?=t('CSS')?></a></li> 
	</ul>		
	
	<div id="ccmCustomCssFormTabs">
	
		<?php Loader::element('custom_style/fonts', array('cssData' => $cssData, 'fh' => $fh));?>
	
		<?php Loader::element('custom_style/background', array('cssData' => $cssData, 'fh' => $fh, 'ah' => $ah));?>
	
		<?php Loader::element('custom_style/border', array('cssData' => $cssData, 'fh' => $fh));?>

		<?php Loader::element('custom_style/spacing', array('cssData' => $cssData, 'fh' => $fh));?>
		
		<?php Loader::element('custom_style/css', array('style' => $style));?>

	</div>
	
	<br/>
	
	<? if ($cspID > 0) { 
		$cspx = CustomStylePreset::getByID($cspID);?>
		<div id="cspFooterPreset" style="display: none">
			<div class="ccm-note-important">
				<h2><?=t('You are changing a preset')?></h2>
				<div><?=$form->radio('cspPresetAction', 'update_existing_preset', true)?> <?=t('Update "%s" preset everywhere it is used', $cspx->getCustomStylePresetName())?></div>
				<div><?=$form->radio('cspPresetAction', 'save_as_custom_style')?> <?=t('Use this style here, and leave "%s" unchanged', $cspx->getCustomStylePresetName())?></div>
				<div><?=$form->radio('cspPresetAction', 'create_new_preset')?> <?=t('Save this style as a new preset')?><br/><span style="margin-left: 20px"><?=$form->text('cspName', array('style' => 'width:  127px', 'disabled' => true))?></span></div>
			</div>
		</div>
	<? } ?>
	
	<div id="cspFooterNoPreset" >
		<?=$form->checkbox('cspPresetAction', 'create_new_preset')?>
		<?=t('Save this style as a new preset.')?>
		<span style="margin-left: 10px">
			<?=$form->text('cspName', array('style' => 'width:  140px', 'disabled' => true))?>
		</span>
	</div>
	
	<br/>
	
	<? if (!$_REQUEST['refresh']) { ?>
		<div class="dialog-buttons">
			<a href="#" class="ccm-button-left cancel btn" onclick="jQuery.fn.dialog.closeTop(); return false"><?=t('Cancel')?></a>
			<a href="javascript:void(0)" onclick="$('#ccmCustomCssForm').submit()" class="btn primary ccm-button-right accept"><span><?=t('Save')?></span></a>
			<? if ($cspID < 1) { ?>
				<a onclick="return ccmCustomStyle.resetAll();" id="ccm-reset-style-button" class="btn ccm-button-right accept" style="margin-right:8px; "><span><?=t('Reset Styles')?></span></a>
			<? } ?>
		</div>
	<? } ?>

	<div class="ccm-spacer"></div> 
	
	<div class="ccm-note" style="margin-top:16px;">
		<?=t('Note: Styles set here are often overridden by those defined within the various block types.')?>
	</div>		
	
<?
$valt = Loader::helper('validation/token');
$valt->output();
?>
</form>

<script type="text/javascript">
	$(function() {
		ccmCustomStyle.initForm();
	});
</script>

<? if (!$_REQUEST['refresh']) { ?>
	</div>
<? } ?>
{'fraction_non_alphanumeric': 0.25121540762902017, 'fraction_numerical': 0.007292445774121167, 'mean_word_length': 6.198519515477793, 'pattern_counts': {'":': 0, '<': 247, '<?xml version=': 0, '>': 313, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4997167', 'n_tokens_mistral': 4177, 'n_tokens_neox': 3961, 'n_words': 660}