<?php
if ($module == 'settings_options') print "<hr />";
print "
<span class='headline'>".LABEL_OPTIONS_WATERMARK."</span>
<div class='form-row'>
	<label for='watermark' class='form-label'>".LABEL_WATERMARK."</label>
	<div class='form-cols'>
		<div class='form-col form-full'>
			<div class='form-controls'>
				<input type='file' class='field' id='watermark' name='watermark' value=''>
			</div><!-- /.form-controls -->
		</div><!-- /.form-col form-1of2 -->
	</div><!-- /.form-cols -->
</div><!-- /.form-row -->";

if ($module != 'gallery_options') {
	$sql = "SELECT id, title, value FROM settings_options WHERE title IN ('c_lightbox_watermark', 'c_thumbnails_watermark') AND c_public = '0' ORDER BY id ASC";
} else {
	$sql = "SELECT id, title, value FROM ".$module." WHERE title IN ('c_lightbox_watermark', 'c_thumbnails_watermark') AND c_public = '0' ORDER BY id ASC";
}

$result = $conn->prepare($sql);
$result->execute();
if ($result->rowCount()){
	while ($arr = $result->fetch()){
		if (defined('LABEL_OPTIONS_'.strtoupper($arr['title']))) $title_str = constant('LABEL_OPTIONS_'.strtoupper($arr['title']));
	  else $title_str = ucwords(str_replace("_", " ", $arr['title']));
	  if ($arr['value']) $arr['value'] = stripcslashes(str_replace("<br />", "", $arr['value']));
	  
		print "
<div class='form-row'>
	<label for='".$arr['title']."' class='form-label'>".$title_str."</label>
	<div class='form-cols'>
		<div class='form-col'>
			<div class='form-controls'>";
		if ($arr['value']){
			print "
				<input type='checkbox' class='field' id='".$arr['title']."' name='".$arr['title']."' value='1' checked='checked'>";
		} else {
			print "
				<input type='checkbox' class='field' id='".$arr['title']."' name='".$arr['title']."' value='1'>";
		}
		print "
			</div><!-- /.form-controls -->
		</div><!-- /.form-col-->
	</div><!-- /.form-cols -->
</div><!-- /.form-row -->";
	}
}

$sql = "SELECT id, title, value FROM settings_options WHERE 
				title IN ('watermark_width', 'watermark_height', 'watermark_ratio', 'watermark_position', 
					'watermark_top', 'watermark_right', 'watermark_bottom', 'watermark_left') AND c_public = '0' 
				ORDER BY FIELD(title, 'watermark_width', 'watermark_height', 'watermark_ratio', 'watermark_position', 
					'watermark_top', 'watermark_right', 'watermark_bottom', 'watermark_left'), id ASC";
$result = $conn->prepare($sql);
$result->execute();
if ($result->rowCount()){
	while ($arr = $result->fetch()){
		if (defined('LABEL_OPTIONS_'.strtoupper($arr['title']))) $title_str = constant('LABEL_OPTIONS_'.strtoupper($arr['title']));
	  else $title_str = ucwords(str_replace("_", " ", $arr['title']));
	  if ($arr['value']) $arr['value'] = stripcslashes(str_replace("<br />", "", $arr['value']));
	  
	  if ($arr['title'] == 'watermark_position'){
			print "
<div class='form-row'>
	<label for='".$arr['title']."' class='form-label'>".$title_str."</label>
	<div class='form-cols'>
		<div class='form-col form-xsmall'>
			<div class='form-controls'>
				<select class='select' name='".$arr['title']."' id='".$arr['title']."'>";
			if ($arr['value'] == 'LT') print "<option value='LT' selected='selected'>".LABEL_OPTIONS_WATERMARK_LT."</option>";
			else print "<option value='LT'>".LABEL_OPTIONS_WATERMARK_LT."</option>";
			if ($arr['value'] == 'RT') print "<option value='RT' selected='selected'>".LABEL_OPTIONS_WATERMARK_RT."</option>";
			else print "<option value='RT'>".LABEL_OPTIONS_WATERMARK_RT."</option>";
			if ($arr['value'] == 'RB') print "<option value='RB' selected='selected'>".LABEL_OPTIONS_WATERMARK_RB."</option>";
			else print "<option value='RB'>".LABEL_OPTIONS_WATERMARK_RB."</option>";
			if ($arr['value'] == 'LB') print "<option value='LB' selected='selected'>".LABEL_OPTIONS_WATERMARK_LB."</option>";
			else print "<option value='LB'>".LABEL_OPTIONS_WATERMARK_LB."</option>";
			print "
				</select>
			</div><!-- /.form-controls -->
		</div><!-- /.form-col -->
	</div><!-- /.form-cols -->
</div><!-- /.form-row -->";
		} else if ($arr['title'] == 'watermark_ratio') {
			print "
<div class='form-row'>
	<label for='".$arr['title']."' class='form-label'>".$title_str."</label>
	<div class='form-cols'>
		<div class='form-col form-xxsmall'>
			<div class='form-controls'>
				<input type='text' class='field' id='".$arr['title']."' name='".$arr['title']."' value='".$arr['value']."'>
			</div><!-- /.form-controls -->
		</div><!-- /.form-col -->
	</div><!-- /.form-cols -->
</div><!-- /.form-row -->";
		} else {
			print "
<div class='form-row'>
	<label for='".$arr['title']."' class='form-label'>".$title_str."</label>
	<div class='form-cols'>
		<div class='form-col form-xxsmall'>
			<div class='form-controls'>
				<input type='text' class='field' id='".$arr['title']."' name='".$arr['title']."' value='".$arr['value']."'>
				<label for='".$arr['title']."' class='form-label-after'>px</label>
			</div><!-- /.form-controls -->
		</div><!-- /.form-col -->
	</div><!-- /.form-cols -->
</div><!-- /.form-row -->";
		}
	}
}

if ($module != 'settings_options') print "<hr />";