<?php
/*
 * \Sentra.Designs\BasicDesigner\images.accordion\toggler\compile-icons.php
 */
 // recolor and save the images into substyles images folder
/* Copy selected icons into the substyles images folder */

//DEBUG($acrd_icons_path);
/* Up-/Down-arrows need to be colorized*/
$srcpath = $wb->PROJECT['templatefull'].DIRECTORY_SEPARATOR.
							"images.accordion".DIRECTORY_SEPARATOR.
							'toggler'.DIRECTORY_SEPARATOR.
							'toggler-up.png';
$dstimgfolder = $wb->PROJECT['template_path'].'images'.DIRECTORY_SEPARATOR;
	// 1. Down-arrow
	If (file_exists($srcpath)) {
		If (!isset($Acrd_open_replace_white)) {
			If (isset($wb ->BDpara['Acrd_open_replace_white'])) {
				$Acrd_open_replace_white = $wb ->BDpara['Acrd_open_replace_white'];
			} Else {
				$Acrd_open_replace_white = '#FFFFFF';
			}
		}
		If (isset($TEMPLATE_PARAMETER['Acrd_open_replace_white'])) {
			$Acrd_open_replace_white = $TEMPLATE_PARAMETER['Acrd_open_replace_white'];
		}

		If (!isset($Acrd_open_replace_black)) {
			If (isset($wb ->BDpara['Acrd_open_replace_black'])) {
				$Acrd_open_replace_black = $wb ->BDpara['Acrd_open_replace_black'];
			} Else {
				$Acrd_open_replace_black = '#000000';
			}
		}
		If (isset($TEMPLATE_PARAMETER['Acrd_open_replace_black'])) {
			$Acrd_open_replace_black = $TEMPLATE_PARAMETER['Acrd_open_replace_black'];
		}

		$success =
		colorize_images($srcpath,										// path to the source image
									 	$dstimgfolder,							// path where the resulting image shall be copied to (specified in process-template-parameter.php)
									 	'open-',										// first part of destination filename
									 	$Acrd_open_replace_white,		// target color which replaces the white part of teh source image
									 	$Acrd_open_replace_black, 	// target color which replaces the black part of the source image
									 	NULL,NULL,TRUE); 						/* Add an substyle dependant img-ID*/
		If (is_bool($success)) {
			If (isset($wb->MAKE_PREVIEW) && $wb->MAKE_PREVIEW) {
				pr(__FILE__.' '.__LINE__.' colorize image not successfull!');
			} Else {
				DEBUG(__FILE__.' '.__LINE__.' colorize image not successfull!');
			}
		} Else {
			$Acrd_icon_opened 			= $success['basename'];
			$Acrd_icon_opened_hover = $success['basename'];
		}
	} Else {
		DEBUG('<br>NOT found: '.$srcpath);
	}

	// 2. Up-arrow
	$srcpath = $wb->PROJECT['templatefull'].DIRECTORY_SEPARATOR.
								"images.accordion".DIRECTORY_SEPARATOR.
								'toggler'.DIRECTORY_SEPARATOR.
								'toggler-down.png';
	If (file_exists($srcpath)) {
		list($Acrd_icon_width,$Acrd_icon_height) = getimagesize($srcpath);
		If (!isset($Acrd_closed_replace_white)) {
			If (isset($wb ->BDpara['Acrd_closed_replace_white'])) {
				$Acrd_closed_replace_white = $wb ->BDpara['Acrd_closed_replace_white'];
			} Else {
				$Acrd_closed_replace_white = '#FFFFFF';
			}
		}
		If (isset($TEMPLATE_PARAMETER['Acrd_closed_replace_white'])) {
			$Acrd_closed_replace_white = $TEMPLATE_PARAMETER['Acrd_closed_replace_white'];
		}

		If (!isset($Acrd_closed_replace_black)) {
			If (isset($wb ->BDpara['Acrd_closed_replace_black'])) {
				$Acrd_closed_replace_black = $wb ->BDpara['Acrd_closed_replace_black'];
			} Else {
				$Acrd_closed_replace_black = '#000000';
			}
		}
		If (isset($TEMPLATE_PARAMETER['Acrd_closed_replace_black'])) {
			$Acrd_closed_replace_black = $TEMPLATE_PARAMETER['Acrd_closed_replace_black'];
		}

		$success =
			colorize_images($srcpath,										// path to the source image
										 	$dstimgfolder,							// path where the resulting image shall be copied to (specified in process-template-parameter.php)
									 		'clsd-',										// first part of destination filename
									 		$Acrd_closed_replace_white,	// target color which replaces the white part of teh source image
									 		$Acrd_closed_replace_black,	// target color which replaces the black part of the source image
										 	NULL,NULL,TRUE); 						/* Add an substyle dependant img-ID*/
		If (is_bool($success)) {
			If (isset($wb->MAKE_PREVIEW) && $wb->MAKE_PREVIEW) {
				pr(__FILE__.' '.__LINE__.' colorize image not successfull!');
			} Else {
				DEBUG(__FILE__.' '.__LINE__.' colorize image not successfull!');
			}
		} Else {
			$Acrd_icon_closed 			= $success['basename'];
			$Acrd_icon_closed_hover = $success['basename'];
		}
	} Else {
		DEBUG('<br>NOT found: '.$srcpath);
	}
//DEBUG($Acrd_icon_opened.'<br>'.$Acrd_icon_closed);
?>