<?php
/**
 * Flexible Posts Widget: Widget Admin Form 
 */

// Block direct requests
if ( !defined('ABSPATH') )
	die('-1');

?>
<div class="dpe-fp-widget">

	<div class="section title">
        <p>
			<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Widget title:'); ?></label> 
			<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />
        </p>
	</div>
    
    <div class="section getemby">
		<h4><?php _e('Get posts by'); ?></h4>
		<div class="inside">
		
			<div id="<?php echo $this->get_field_id('getemby'); ?>" class="categorydiv getembytabs">
				
				<input id="<?php echo $this->get_field_id('cur_tab'); ?>" class="cur_tab" name="<?php echo $this->get_field_name('cur_tab'); ?>" type="hidden" value="<?php echo $cur_tab; ?>" />
				
				
				
				<div id="<?php echo $this->get_field_id('getemby-pt'); ?>" class="tabs-panel pt">
					<?php $this->posttype_checklist( $posttype ); ?>
				</div><!-- .pt.getemby -->
				
				<div id="<?php echo $this->get_field_id('getemby-tt'); ?>" class="tabs-panel tt" style="display:none;">
					<p>	
						<label for="<?php echo $this->get_field_id('taxonomy'); ?>"><?php _e('Select a taxonomy:'); ?></label> 
						<select class="widefat dpe-fp-taxonomy" name="<?php echo $this->get_field_name('taxonomy'); ?>" id="<?php echo $this->get_field_id('taxonomy'); ?>">
							<option value="none" <?php echo 'none' == $taxonomy ? ' selected="selected"' : ''; ?>>Ignore Taxonomy &amp; Term</option>
							<?php
							foreach ($this->taxonomies as $option) {
								echo '<option value="' . $option->name . '"', $taxonomy == $option->name ? ' selected="selected"' : '', '>', $option->label, '</option>';
							}
							?>
						</select>		
					</p>
					<label <?php echo 'none' == $taxonomy ? ' style="display:none;"' : ''; ?>><?php _e('Select terms:'); ?></label> 
					<div class="terms" <?php echo 'none' == $taxonomy ? ' style="display:none;"' : ''; ?>>
						<?php
							if ( !empty($taxonomy) && 'none' != $taxonomy ) {
							
								$args = array (
									'hide_empty' => 0,
								);
								
								$terms = get_terms( $taxonomy, $args );
								
								if( !empty( $terms ) ) {
									$output .= '<ul class="categorychecklist termschecklist form-no-clear">';
									foreach ( $terms as $option ) {
										$output .= "\n<li>" . '<label class="selectit"><input value="' . esc_attr( $option->slug ) . '" type="checkbox" name="' . $this->get_field_name('term') . '[]"' . checked( in_array( $option->slug, (array)$term ), true, false ) . ' /> ' . esc_html( $option->name ) . "</label></li>\n";
									}
									$output .= "</ul>\n";
								} else {
									$output = '<p>No terms found.</p>';
								}
								
								echo ( $output );
							}
						?>
					</div>
				</div><!-- .tt.getemby -->
			
			</div><!-- #<?php echo $this->get_field_id('getemby'); ?> -->
			
		</div><!-- .inside -->
	
	</div>
	
	<div class="section display">
		<h4>Display options</h4>
		<p class="cf">
          <label for="<?php echo $this->get_field_id('number'); ?>"><?php _e('Number of posts to show:'); ?></label> 
          <input id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" />
        </p>
		<p class="cf">
          <label for="<?php echo $this->get_field_id('offset'); ?>"><?php _e('Number of posts to skip:'); ?></label> 
          <input id="<?php echo $this->get_field_id('offset'); ?>" name="<?php echo $this->get_field_name('offset'); ?>" type="text" value="<?php echo $offset; ?>" />
        </p>
   		<p class="cf">
			<label for="<?php echo $this->get_field_id('orderby'); ?>"><?php _e('Order posts by:'); ?></label> 
			<select name="<?php echo $this->get_field_name('orderby'); ?>" id="<?php echo $this->get_field_id('orderby'); ?>">
				<?php
				foreach ( $this->orderbys as $key => $value ) {
					echo '<option value="' . $key . '" id="' . $this->get_field_id( $key ) . '"', $orderby == $key ? ' selected="selected"' : '', '>', $value, '</option>';
				}
				?>
			</select>		
		</p>
		<p class="cf">
			<label for="<?php echo $this->get_field_id('order'); ?>"><?php _e('Order:'); ?></label> 
			<select name="<?php echo $this->get_field_name('order'); ?>" id="<?php echo $this->get_field_id('order'); ?>">
				<?php
				foreach ( $this->orders as $key => $value ) {
					echo '<option value="' . $key . '" id="' . $this->get_field_id( $key ) . '"', $order == $key ? ' selected="selected"' : '', '>', $value, '</option>';
				}
				?>
			</select>		
		</p>
	</div>
	

	

	
</div><!-- .dpe-fp-widget -->