<?php

/**
 * Provide a admin area view for the "options"-page of the plugin
 *
 * This file is used to markup the admin-facing aspects of the plugin.
 *
 * @link       http://www.weedesign.de/weebotLite.html
 * @since      1.0.0
 *
 * @package    weebotLite
 * @subpackage weebotLite/admin/template
 */
 
?>

<div class="wrap">

	<?php
		/* 
		*	if an action is defined
		*/
		if(isset($_GET["action"])) {
		
			/* 
			*	delete the database
			*/
			if($_GET["action"]=="delete") {
				?><div id="message" class="updated notice is-dismissible"><p><?php echo esc_html( "Database successfully removed" ); ?>.</p><button type="button" class="notice-dismiss"><span class="screen-reader-text"><?php echo esc_html( "Dismiss" ); ?>.</span></button></div><?php
			} 
			
			/* 
			*	empty the database
			*/
			if($_GET["action"]=="empty") {
				?><div id="message" class="updated notice is-dismissible"><p><?php echo esc_html( "Database successfully emptied" ); ?>.</p><button type="button" class="notice-dismiss"><span class="screen-reader-text"><?php echo esc_html( "Dismiss" ); ?>.</span></button></div><?php
			}
		}
	?>

	<h2><?php echo esc_html( get_admin_page_title() ); ?></h2>

	<form method="post" name="weebotLite_options" action="options.php">

		<?php
		
			/* 
			*	get the plugin-options
			*/
			$options = get_option($this->plugin_name,$this->default_options());
			settings_fields( $this->plugin_name );
			do_settings_sections( $this->plugin_name);
			
		?>			
		
		<h2 class="nav-tab-wrapper"><?php esc_attr_e( 'Design', $this->plugin_name ); ?></h2>
		
		<table class="form-table">
			<tr>
				<th scope="row"><span><?php esc_attr_e( 'Theme', $this->plugin_name ); ?></span></th>
				<td> 
					<?php
						/* 
						*	get all themes
						*/
						$themes = $this->get_themes();
						foreach($themes as $theme => $theme_data) {
							?>
							<fieldset>
								<label for="theme-<?php echo $this->plugin_name;?>-<?php echo $theme;?>">
									<input type="radio" id="theme-<?php echo $this->plugin_name;?>-<?php echo $theme;?>" name="<?php echo $this->plugin_name;?>[theme]" value="<?php echo $theme; ?>" <?php if($theme==$options["theme"]) { ?>checked="checked"<?php } ?> />
									<strong><?php esc_attr_e( $theme, $this->plugin_name ); ?></strong>
									<p class="description"><?php esc_attr_e( $theme_data["description"], $this->plugin_name ); ?>.</p>
								</label>
							</fieldset>
							<?php
						}
					?>
				</td>
			</tr>
			<tr>
				<th scope="row"><span><?php esc_attr_e( 'Chat width', $this->plugin_name ); ?></span></th>
				<td> 
					<fieldset>
						<legend class="screen-reader-text"><span><?php esc_attr_e( 'Chat width', $this->plugin_name ); ?></span></legend>
						<label for="<?php echo $this->plugin_name;?>-chat-width">
							<input type="text" id="<?php echo $this->plugin_name;?>-chat-width" name="<?php echo $this->plugin_name;?>[chat:width]" value="<?php echo $options['chat:width']; ?>"  />
							<p class="description"><?php esc_attr_e( 'The width of the support-chat as CSS value (eg. 30wh, 300px, 20%)', $this->plugin_name ); ?>.</p>
						</label>
					</fieldset>
				</td>
			</tr>
			<tr>
				<th scope="row"><span><?php esc_attr_e( 'Seconds', $this->plugin_name ); ?></span></th>
				<td> 
					<fieldset>
						<legend class="screen-reader-text"><span><?php esc_attr_e( 'Seconds', $this->plugin_name ); ?></span></legend>
						<label for="<?php echo $this->plugin_name;?>-chat-seconds">
							<input type="number" id="<?php echo $this->plugin_name;?>-chat-seconds" name="<?php echo $this->plugin_name;?>[chat:seconds]" value="<?php echo $options['chat:seconds']; ?>"  />
							<p class="description"><?php esc_attr_e( 'After this amount of seconds the chat will be visible', $this->plugin_name ); ?>.</p>
						</label>
					</fieldset>
				</td>
			</tr>
		</table>
			
		<h2 class="nav-tab-wrapper"><?php esc_attr_e( 'Chat', $this->plugin_name ); ?></h2>
		
		<table class="form-table">
			<tr>
				<th scope="row"><span><?php esc_attr_e( 'Active', $this->plugin_name ); ?></span></th>
				<td> 
					<fieldset>
						<legend class="screen-reader-text"><span><?php esc_attr_e( 'Active', $this->plugin_name ); ?></span></legend>
						<label for="<?php echo $this->plugin_name;?>-chat">
							<input type="checkbox" id="<?php echo $this->plugin_name;?>-chat" name="<?php echo $this->plugin_name;?>[chat]" value="1" <?php checked( $options['chat'], 1 ); ?> />
							<p class="description"><?php esc_attr_e( 'This will activate the Support-Chat', $this->plugin_name ); ?>.</p>
						</label>
					</fieldset>
				</td>
			</tr>
			<tr>
				<th scope="row"><span><?php esc_attr_e( 'Welcome Message', $this->plugin_name ); ?></span></th>
				<td> 
					<fieldset>
						<legend class="screen-reader-text"><span><?php esc_attr_e( 'Welcome Message', $this->plugin_name ); ?></span></legend>
						<label for="<?php echo $this->plugin_name;?>-chat-welcome">
							<input type="text" id="<?php echo $this->plugin_name;?>-chat-welcome" name="<?php echo $this->plugin_name;?>[chat:welcome]" value="<?php echo $options['chat:welcome']; ?>"  />
							<p class="description"><?php esc_attr_e( 'The welcome message for new users with an empty chat-log', $this->plugin_name ); ?>.</p>
						</label>
					</fieldset>
				</td>
			</tr>
			<tr>
				<th scope="row"><span><?php esc_attr_e( 'Footer', $this->plugin_name ); ?></span></th>
				<td> 
					<fieldset>
						<legend class="screen-reader-text"><span><?php esc_attr_e( 'Footer', $this->plugin_name ); ?></span></legend>
						<label for="<?php echo $this->plugin_name;?>-footer">
							<input type="checkbox" id="<?php echo $this->plugin_name;?>-footer" name="<?php echo $this->plugin_name;?>[footer]" value="1" <?php checked( $options['footer'], 1 ); ?> />
							<p class="description"><?php esc_attr_e( 'Add the Support-Chat to the bottom of the page. (disable this, if you want to add the Support-Chat via shortcode)', $this->plugin_name ); ?>.</p>
						</label>
					</fieldset>
				</td>
			</tr>
			<tr>
				<th scope="row"><span><?php esc_attr_e( 'Chat-Log Messages', $this->plugin_name ); ?></span></th>
				<td> 
					<fieldset>
						<legend class="screen-reader-text"><span><?php esc_attr_e( 'Chat-Log Messages', $this->plugin_name ); ?></span></legend>
						<label for="<?php echo $this->plugin_name;?>-chat-messages-limit">
							<input type="number" id="<?php echo $this->plugin_name;?>-chat-messages-limit" name="<?php echo $this->plugin_name;?>[chat:messages:limit]" value="<?php echo $options['chat:messages:limit']; ?>"  />
							<p class="description"><?php esc_attr_e( 'This amount of messages will be loaded into the chat-log on initial load', $this->plugin_name ); ?>.</p>
						</label>
					</fieldset>
				</td>
			</tr>
			<tr>
				<th scope="row"><span><?php esc_attr_e( 'Page parameter', $this->plugin_name ); ?></span></th>
				<td> 
					<fieldset>
						<legend class="screen-reader-text"><span><?php esc_attr_e( 'Page parameter', $this->plugin_name ); ?></span></legend>
						<label for="<?php echo $this->plugin_name;?>-page-parameter">
							<input type="checkbox" id="<?php echo $this->plugin_name;?>-page-parameter" name="<?php echo $this->plugin_name;?>[page:parameter]" value="1" <?php checked( $options['page:parameter'], 1 ); ?>  />
							<p class="description"><?php esc_attr_e( 'Remove URL-parameters for page-related answers', $this->plugin_name ); ?>.</p>
						</label>
					</fieldset>
				</td>
			</tr>
			<tr>
				<th scope="row"><span><?php esc_attr_e( 'Page hashtag', $this->plugin_name ); ?></span></th>
				<td> 
					<fieldset>
						<legend class="screen-reader-text"><span><?php esc_attr_e( 'Page hashtag', $this->plugin_name ); ?></span></legend>
						<label for="<?php echo $this->plugin_name;?>-page-hash">
							<input type="checkbox" id="<?php echo $this->plugin_name;?>-page-hash" name="<?php echo $this->plugin_name;?>[page:hash]" value="1" <?php checked( $options['page:hash'], 1 ); ?>  />
							<p class="description"><?php esc_attr_e( 'Remove URL-hashtag for page-related answers', $this->plugin_name ); ?>.</p>
						</label>
					</fieldset>
				</td>
			</tr>
			<tr>
				<th scope="row"><span><?php esc_attr_e( 'Logged Users', $this->plugin_name ); ?></span></th>
				<td> 
					<fieldset>
						<legend class="screen-reader-text"><span><?php esc_attr_e( 'Only logged users', $this->plugin_name ); ?></span></legend>
						<label for="<?php echo $this->plugin_name;?>-chat-logged">
							<input type="checkbox" id="<?php echo $this->plugin_name;?>-chat-logged" name="<?php echo $this->plugin_name;?>[chat:logged]" value="1" <?php checked( $options['chat:logged'], 1 ); ?>  />
							<p class="description"><?php esc_attr_e( 'Show Chat only to logged in visitors', $this->plugin_name ); ?>.</p>
						</label>
					</fieldset>
				</td>
			</tr>
		</table>
		
		<h2 class="nav-tab-wrapper"><?php esc_attr_e( 'Support-User', $this->plugin_name ); ?></h2>
		
		<table class="form-table">
			<tr>
				<th scope="row"><span><?php esc_attr_e( 'Support-User', $this->plugin_name ); ?></span></th>
				<td> 
					<fieldset>
						<legend class="screen-reader-text"><span><?php esc_attr_e( 'Support', $this->plugin_name ); ?></span></legend>
						<label for="<?php echo $this->plugin_name;?>-support">
							<input type="checkbox" id="<?php echo $this->plugin_name;?>-support" name="<?php echo $this->plugin_name;?>[support]" value="1" <?php checked( $options['support'], 1 ); ?>  />
							<p class="description"><?php esc_attr_e( 'Add available Support-User to chat', $this->plugin_name ); ?>.</p>
						</label>
					</fieldset>
				</td>
			</tr>
			<tr>
				<th scope="row"><span><?php esc_attr_e( 'Hide', $this->plugin_name ); ?></span></th>
				<td> 
					<fieldset>
						<legend class="screen-reader-text"><span><?php esc_attr_e( 'Hide chat', $this->plugin_name ); ?></span></legend>
						<label for="<?php echo $this->plugin_name;?>-chat-hide">
							<input type="checkbox" id="<?php echo $this->plugin_name;?>-chat-hide" name="<?php echo $this->plugin_name;?>[chat:hide]" value="1" <?php checked( $options['chat:hide'], 1 ); ?> />
							<p class="description"><?php esc_attr_e( 'Hide Chat for Support-User in frontend', $this->plugin_name ); ?>.</p>
						</label>
					</fieldset>
				</td>
			</tr>
			<tr>
				<th scope="row"><span><?php esc_attr_e( 'Popup', $this->plugin_name ); ?></span></th>
				<td> 
					<fieldset>
						<legend class="screen-reader-text"><span><?php esc_attr_e( 'Show questions', $this->plugin_name ); ?></span></legend>
						<label for="<?php echo $this->plugin_name;?>-chat-questions">
							<input type="checkbox" id="<?php echo $this->plugin_name;?>-chat-questions" name="<?php echo $this->plugin_name;?>[chat:questions]" value="1" <?php checked( $options['chat:questions'], 1 ); ?> />
							<p class="description"><?php esc_attr_e( 'Show new Support-Messages in frontend', $this->plugin_name ); ?>.</p>
						</label>
					</fieldset>
				</td>
			</tr>
			<tr>
				<th scope="row"><span><?php esc_attr_e( 'Show Supporter', $this->plugin_name ); ?></span></th>
				<td> 
					<fieldset>
						<legend class="screen-reader-text"><span><?php esc_attr_e( 'Show Supporter', $this->plugin_name ); ?></span></legend>
						<label for="<?php echo $this->plugin_name;?>-chat-supporter">
							<input type="checkbox" id="<?php echo $this->plugin_name;?>-chat-supporter" name="<?php echo $this->plugin_name;?>[chat:supporter]" value="1" <?php checked( $options['chat:supporter'], 1 ); ?>  />
							<p class="description"><?php esc_attr_e( 'Show all Support-Users for new users with an empty chat-log', $this->plugin_name ); ?>.</p>
						</label>
					</fieldset>
				</td>
			</tr>
		</table>
		
		<h2 class="nav-tab-wrapper"><?php esc_attr_e( 'User', $this->plugin_name ); ?></h2>
		
		<table class="form-table">
			<tr>
				<th scope="row"><span><?php esc_attr_e( 'Online', $this->plugin_name ); ?></span></th>
				<td> 
					<fieldset>
						<legend class="screen-reader-text"><span><?php esc_attr_e( 'Online', $this->plugin_name ); ?></span></legend>
						<label for="<?php echo $this->plugin_name;?>-online">
							<input type="checkbox" id="<?php echo $this->plugin_name;?>-online" name="<?php echo $this->plugin_name;?>[online]" value="1" <?php checked( $options['online'], 1 ); ?>  />
							<p class="description"><?php esc_attr_e( 'Track online users', $this->plugin_name ); ?>.</p>
						</label>
					</fieldset>
				</td>
			</tr>
		</table>
		
		<h2 id="spam" class="nav-tab-wrapper"><?php esc_attr_e( 'Spam', $this->plugin_name ); ?></h2>
		
		<table class="form-table">
			<tr>
				<th scope="row"><span><?php esc_attr_e( 'Active', $this->plugin_name ); ?></span></th>
				<td> 
					<fieldset>
						<legend class="screen-reader-text"><span><?php esc_attr_e( 'Active', $this->plugin_name ); ?></span></legend>
						<label for="<?php echo $this->plugin_name;?>-spam">
							<input type="checkbox" id="<?php echo $this->plugin_name;?>-spam" name="<?php echo $this->plugin_name;?>[spam]" value="1" <?php checked( $options['spam'], 1 ); ?> />
							<p class="description"><?php esc_attr_e( 'Activate Spam Check', $this->plugin_name ); ?>.</p>
						</label>
					</fieldset>
				</td>
			</tr>
			<tr>
				<th scope="row"><span><?php esc_attr_e( 'Text Length', $this->plugin_name ); ?></span></th>
				<td> 
					<fieldset>
						<legend class="screen-reader-text"><span><?php esc_attr_e( 'Chars', $this->plugin_name ); ?></span></legend>
						<label for="<?php echo $this->plugin_name;?>-spam-chars">
							<input type="number" id="<?php echo $this->plugin_name;?>-spam-chars" name="<?php echo $this->plugin_name;?>[spam:chars]" value="<?php echo ( $options['spam:chars'] ); ?>" />
							<p class="description"><?php esc_attr_e( 'Minimum Chars for a text', $this->plugin_name ); ?>.</p>
						</label>
					</fieldset>
				</td>
			</tr>
			<tr>
				<th scope="row"><span><?php esc_attr_e( 'Words', $this->plugin_name ); ?></span></th>
				<td> 
					<fieldset>
						<legend class="screen-reader-text"><span><?php esc_attr_e( 'Active', $this->plugin_name ); ?></span></legend>
						<label for="<?php echo $this->plugin_name;?>-spam-words">
							<input type="checkbox" id="<?php echo $this->plugin_name;?>-spam-words" name="<?php echo $this->plugin_name;?>[spam:words]" value="1" <?php checked( $options['spam:words'], 1 ); ?> />
							<p class="description"><?php esc_attr_e( 'Activate Word Check', $this->plugin_name ); ?>.</p>
						</label>
					</fieldset>
				</td>
			</tr>
			<tr>
				<th scope="row"><span><?php esc_attr_e( 'Included Words', $this->plugin_name ); ?></span></th>
				<td> 
					<fieldset>
						<legend class="screen-reader-text"><span><?php esc_attr_e( 'Included Words', $this->plugin_name ); ?></span></legend>
						<label for="<?php echo $this->plugin_name;?>-spam-words-include">
							<input type="text" id="<?php echo $this->plugin_name;?>-spam-words-include" name="<?php echo $this->plugin_name;?>[spam:words:include]" value="<?php echo ( $options['spam:words:include'] ); ?>" />
							<p class="description"><?php esc_attr_e( 'One of these words should be in the text (comma separated)', $this->plugin_name ); ?>.</p>
						</label>
					</fieldset>
				</td>
			</tr>
			<tr>
				<th scope="row"><span><?php esc_attr_e( 'Excluded Words', $this->plugin_name ); ?></span></th>
				<td> 
					<fieldset>
						<legend class="screen-reader-text"><span><?php esc_attr_e( 'Excluded Words', $this->plugin_name ); ?></span></legend>
						<label for="<?php echo $this->plugin_name;?>-spam-words-exclude">
							<input type="text" id="<?php echo $this->plugin_name;?>-spam-words-exclude" name="<?php echo $this->plugin_name;?>[spam:words:exclude]" value="<?php echo ( $options['spam:words:exclude'] ); ?>" />
							<p class="description"><?php esc_attr_e( 'All of these words should not be in the text (comma separated)', $this->plugin_name ); ?>.</p>
						</label>
					</fieldset>
				</td>
			</tr>
			<tr>
				<th scope="row"><span><?php esc_attr_e( 'Excluded Strings', $this->plugin_name ); ?></span></th>
				<td> 
					<fieldset>
						<legend class="screen-reader-text"><span><?php esc_attr_e( 'Excluded Strings', $this->plugin_name ); ?></span></legend>
						<label for="<?php echo $this->plugin_name;?>-spam-strings-exclude">
							<input type="text" id="<?php echo $this->plugin_name;?>-spam-strings-exclude" name="<?php echo $this->plugin_name;?>[spam:strings:exclude]" value="<?php echo ( $options['spam:strings:exclude'] ); ?>" />
							<p class="description"><?php esc_attr_e( 'All of these strings should not be in the text (comma separated)', $this->plugin_name ); ?>.</p>
						</label>
					</fieldset>
				</td>
			</tr>
		</table>
		
		<?php submit_button(FALSE, 'primary', 'submit', TRUE); ?>

    </form>

</div>
