<?php
include_once('RCCWP_Options.php');

class RCCWP_OptionsPage
{

function Main()
{
	$customWritePanels = RCCWP_CustomWritePanel::GetCustomWritePanels();
	$customWritePanelOptions = RCCWP_Options::Get();

	if (function_exists('is_site_admin') && !is_site_admin())
		update_option("Flutter_notTopAdmin", true);
	else
		update_option("Flutter_notTopAdmin", false);

	?>
	
	<div class="wrap">

	<h2>Flutter Options</h2>
	
	<form action="" method="post" id="custom-write-panel-options-form">	
	

	<h3>Write Panel Options</h3>
	<table class="form-table" width="100%" border="0" cellspacing="0" cellpadding="6"> 

	<tr valign="top">
		<th scope="row">Hide Post Panel</th>
        	<td>
			<label for="hide-write-post"> 
			<input name="hide-write-post" id="hide-write-post" value="1" <?php echo RCCWP_OptionsPage::GetCheckboxState($customWritePanelOptions['hide-write-post'])?> type="checkbox">
			&nbsp; Hide Wordpress Post panel</label> 
		</td>
        </tr>
 
    	<tr valign="top">
		<th scope="row">Hide Page Panel</th>
		<td>
			<label for="hide-write-page"> 
			<input name="hide-write-page" id="hide-write-page" value="1" <?php echo RCCWP_OptionsPage::GetCheckboxState($customWritePanelOptions['hide-write-page'])?> type="checkbox">
			&nbsp; Hide Wordpress Page panel</label> 
 		</td>
        </tr>

    	<tr valign="top">
		<th scope="row">Editing Prompt</th>
		<td>
			<label for="prompt-editing-post"> 
			<input name="prompt-editing-post" id="prompt-editing-post" value="1" <?php echo RCCWP_OptionsPage::GetCheckboxState($customWritePanelOptions['prompt-editing-post'])?> type="checkbox"> 
			&nbsp; Prompt when editing a Post not created with Custom Write Panel.</label> 
		</td>
        </tr>

    	<tr valign="top">
		<th scope="row">Assign to Role</th>
        	<td>
			<label for="assign-to-role"> 
			<input name="assign-to-role" id="assign-to-role" value="1" <?php echo RCCWP_OptionsPage::GetCheckboxState($customWritePanelOptions['assign-to-role'])?> type="checkbox"> 
			&nbsp; This option will create a capability for each write panel such that the write panel is accessible by the Administrator only by default.
			 You can assign the write panel to other roles using </label><a target="_blank" href="http://sourceforge.net/projects/role-manager">Role Manager Plugin</a>. 
		</td>
        </tr>

    	<tr valign="top">
		<th scope="row">Default Panel</th>
		<td>
		
			<label for="default-custom-write-panel">
			<select name="default-custom-write-panel" id="default-custom-write-panel">
				<option value="">(None)</option>
			<?php
				$defaultCustomWritePanel = $customWritePanelOptions['default-custom-write-panel'];
				foreach ($customWritePanels as $panel) :
					$selected = $panel->id == $defaultCustomWritePanel ? 'selected="selected"' : '';
			?>
				<option value="<?php echo $panel->id?>" <?php echo $selected?>><?php echo $panel->name?></option>
			<?php
				endforeach;
			?>
			</select>
			</label>
		
		</td>
        </tr>

	</table>


	<br />
	<h3>Layout Options</h3>
	<p>Allows you to add modules to the blog.</p>
	<table class="form-table" width="100%" border="0" cellspacing="0" cellpadding="6"> 

	<tr valign="top">
		<th scope="row">Layout Tab</th>
		<td>
			<label for="canvas_show"> 
			<input name="canvas_show" id="canvas_show" value="1" <?php echo RCCWP_OptionsPage::GetCheckboxState($customWritePanelOptions['canvas_show'])?> type="checkbox"> 
			&nbsp; Show Layout tab.</label> 
		</td>
        </tr>


	<tr valign="top">
		<th scope="row">Style Tab</th>
		<td>
			<label for="ink_show"> 
			<input name="ink_show" id="ink_show" value="1" <?php echo RCCWP_OptionsPage::GetCheckboxState($customWritePanelOptions['ink_show'])?> type="checkbox"> 
			&nbsp; Show Style tab.</label> 
		</td>
        </tr>


	<tr valign="top">
		<th scope="row">Layout Instructions</th>
		<td>
			<label for="canvas_show_instructions"> 
			<input name="canvas_show_instructions" id="canvas_show_instructions" value="1" <?php echo RCCWP_OptionsPage::GetCheckboxState($customWritePanelOptions['canvas_show_instructions'])?> type="checkbox"> 
			&nbsp; Display the instructions on the Layout page.</label> 
		</td>
        </tr>


	<tr valign="top">
		<th scope="row">Zones Names</th>
		<td>
			<label for="canvas_show_zone_name"> 
			<input name="canvas_show_zone_name" id="canvas_show_zone_name" value="1" <?php echo RCCWP_OptionsPage::GetCheckboxState($customWritePanelOptions['canvas_show_zone_name'])?> type="checkbox"> 
			&nbsp; Show zones names on droppable zones.</label> 
		</td>
        </tr>

	</table>

	<?php if (version_compare(PHP_VERSION, '5.0.0') === 1){ ?>
	<br />
	<h3>HTML Purifier</h3>
	<p>Ensures the post is valid XHTML. (php5 only)</p>
	<table class="form-table" width="100%" border="0" cellspacing="0" cellpadding="6"> 

	<tr valign="top">
		<th scope="row">HTML Purifier</th>
		<td>
			<label for="enable-HTMLPurifier"> 
			<input name="enable-HTMLPurifier" id="enable-HTMLPurifier" value="1" <?php echo RCCWP_OptionsPage::GetCheckboxState($customWritePanelOptions['enable-HTMLPurifier'])?> type="checkbox"> 
			&nbsp; Enable HTML Purifier.</label> 
		</td>
        </tr>

	<tr valign="top">
		<th scope="row">Tidy level</th>
		<td>
		<select name="tidy-level" id="tidy-level">		
			<option <?php if ('none' == $customWritePanelOptions['tidy-level']) echo "selected"; ?> value="none">none</option>
			<option <?php if ('light' == $customWritePanelOptions['tidy-level']) echo "selected"; ?> value="light">light</option>
			<option <?php if ('medium' == $customWritePanelOptions['tidy-level']) echo "selected"; ?> value="medium">medium</option>
			<option <?php if ('heavy' == $customWritePanelOptions['tidy-level']) echo "selected"; ?> value="heavy">heavy</option>
		</select>
		</td>
        </tr>
	
	</table>
	<?php } ?>

	<br />
	<h3>Other Options</h3>
	<table class="form-table" width="100%" border="0" cellspacing="0" cellpadding="6">

    	<tr valign="top">
		<th scope="row">Snipshot</th>
		<td>
			<label for="use-snipshot"> 
			<input name="use-snipshot" id="use-snipshot" value="1" <?php echo RCCWP_OptionsPage::GetCheckboxState($customWritePanelOptions['use-snipshot'])?> type="checkbox"> 
			&nbsp; Use Snipshot services instead of cropper to edit photos.</label> 
		</td>
        </tr>

	<tr valign="top">
		<th scope="row">Edit-n-place</th>
		<td>
			<label for="enable-editnplace"> 
			<input name="enable-editnplace" id="enable-editnplace" value="1" <?php echo RCCWP_OptionsPage::GetCheckboxState($customWritePanelOptions['enable-editnplace'])?> type="checkbox"> 
			&nbsp; Edit posts instantly from the post page.</label> 
		</td>
        </tr>

	<tr>
		<th scope="row">Use Flash Uploader</th>
		<td>
			<label for="enable-swfupload">
			<input name="enable-swfupload" id="enable-swfupload" value="1" <?php echo RCCWP_OptionsPage::GetCheckboxState($customWritePanelOptions['enable-swfupload']) ?> type="checkbox">
			&nbsp; Use Flash Uploader instead of Browser upload. </label>
		</td>
	</tr>

	</table>

	<br />	
	<h3>Uninstall Flutter</h3>
	<table class="form-table" width="100%" border="0" cellspacing="0" cellpadding="6"> 

    	<tr valign="top">
		<th scope="row">Uninstall Flutter</th>
		<td>
			<input type="text" id="uninstall-custom-write-panel" name="uninstall-custom-write-panel" size="25" /><br />
			<label for="uninstall-custom-write-panel">
			&nbsp; Type <strong>uninstall</strong> into the textbox, click <strong>Update Options</strong>, and all the tables created by this plugin will be deleted</label>
		
		</td>
        </tr>

	</table>

	<p class="submit" ><input name="update-custom-write-panel-options" type="submit" value="Update Options" /></p>
	
	</form>

	</div>
	
	<?php
}

function GetCheckboxState($optionValue)
{
	if ($optionValue == '' || $optionValue == 0)
		return '';
	else 
		return 'checked="checked"';
}

}

?>