<?php 

add_action('dslc_hook_register_modules',
     create_function('', 'return dslc_register_module( "Ainex_Pricing_Table_1" );')
);

class Ainex_Pricing_Table_1 extends DSLC_Module {
 		
 	// Module Attributes
    var $module_id = 'Ainex_Pricing_Table_1';
    var $module_title = 'Pricing Table 1';
    var $module_icon = 'dollar';
    var $module_category = 'Ainex - Pricing Table';
 
 	// Module Options
    function options() { 
				
    	// The options array
    	$dslc_options = array(
			array(
				'label' => 'Columns - Pricing Table 1',
				'id' => 'columns',
				'std' => '4',
				'type' => 'select',
				'section' => 'styling',
				'choices' => array(
					array(
						'label' => '3 Columns',
						'value' => '3'
					),
					array(
						'label' => '4 Columns',
						'value' => '4'
					),
				)
			),

			/*
			 * Column 1
			*/
			array(
				'label' => 'Title',
				'id' => 'title1',
				'std' => 'Enterprise',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 1',
			),
			array(
				'label' => 'Content',
				'id' => 'content1',
				'std' => '10GB Disk Space
				    100GB Monthly Bandwidth
				    20 Email Accounts
				    Unlimited subdomains
				',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 1',
			),
			array(
				'label' => 'Currency',
				'id' => 'currency1',
				'std' => '$',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 1',
			),
			array(
				'label' => 'Price',
				'id' => 'price1',
				'std' => '59',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 1',
			),
			array(
				'label' => 'Price per month/year',
				'id' => 'price_per1',
				'std' => 'per month',
				'type' => 'text',
				'section' => 'Column 1',
			),
			array(
				'label' => 'Button Text',
				'id' => 'buttontext1',
				'std' => 'Sign up',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 1',
			),
			array(
				'label' => 'Button Link URL',
				'id' => 'button_link1',
				'std' => '#',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 1',
			),
			array(
				'label' => 'Highlights',
				'id' => 'highlights1',
				'std' => '0',
				'type' => 'select',
				'section' => 'styling',
				'tab'		=> 'Column 1',
				'choices' => array(
					array(
						'label' => 'No',
						'value' => '0'
					),
					array(
						'label' => 'Yes',
						'value' => '1'
					),
				)
			),
			array(
				'label' => 'Text Highlights',
				'id' => 'text_highlight1',
				'std' => 'Enterprise',
				'type' => 'text',
				'section' => 'Column 1',
			),

			/*
			 * Column 2
			*/
			array(
				'label' => 'Title',
				'id' => 'title2',
				'std' => 'Professional',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 2',
			),
			array(
				'label' => 'Content',
				'id' => 'content2',
				'std' => '5GB Disk Space
				    50GB Monthly Bandwidth
				    10 Email Accounts
				    Unlimited subdomains
				',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 2',
			),
			array(
				'label' => 'Currency',
				'id' => 'currency2',
				'std' => '$',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 2',
			),
			array(
				'label' => 'Price',
				'id' => 'price2',
				'std' => '29',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 2',
			),
			array(
				'label' => 'Price per month/year',
				'id' => 'price_per2',
				'std' => 'per month',
				'type' => 'text',
				'section' => 'Column 2',
			),
			array(
				'label' => 'Button Text',
				'id' => 'buttontext2',
				'std' => 'Sign up',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 2',
			),
			array(
				'label' => 'Button Link URL',
				'id' => 'button_link2',
				'std' => '#',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 2',
			),
			array(
				'label' => 'Highlights',
				'id' => 'highlights2',
				'std' => '1',
				'type' => 'select',
				'section' => 'styling',
				'tab'		=> 'Column 2',
				'choices' => array(
					array(
						'label' => 'No',
						'value' => '0'
					),
					array(
						'label' => 'Yes',
						'value' => '1'
					),
				)
			),
			array(
				'label' => 'Text Highlights',
				'id' => 'text_highlight2',
				'std' => 'Professional',
				'type' => 'text',
				'section' => 'Column 2',
			),

			/*
			 * Column 3
			*/
			array(
				'label' => 'Title',
				'id' => 'title3',
				'std' => 'Standard',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 3',
			),
			array(
				'label' => 'Content',
				'id' => 'content3',
				'std' => '3GB Disk Space
				    25GB Monthly Bandwidth
				    5 Email Accounts
				    Unlimited subdomains
				',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 3',
			),
			array(
				'label' => 'Currency',
				'id' => 'currency3',
				'std' => '$',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 3',
			),
			array(
				'label' => 'Price',
				'id' => 'price3',
				'std' => '17',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 3',
			),
			array(
				'label' => 'Price per month/year',
				'id' => 'price_per3',
				'std' => 'per month',
				'type' => 'text',
				'section' => 'Column 3',
			),
			array(
				'label' => 'Button Text',
				'id' => 'buttontext3',
				'std' => 'Sign up',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 3',
			),
			array(
				'label' => 'Button Link URL',
				'id' => 'button_link3',
				'std' => '#',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 3',
			),
			array(
				'label' => 'Highlights',
				'id' => 'highlights3',
				'std' => '0',
				'type' => 'select',
				'section' => 'styling',
				'tab'		=> 'Column 3',
				'choices' => array(
					array(
						'label' => 'No',
						'value' => '0'
					),
					array(
						'label' => 'Yes',
						'value' => '1'
					),
				)
			),
			array(
				'label' => 'Text Highlights',
				'id' => 'text_highlight3',
				'std' => 'Standard',
				'type' => 'text',
				'section' => 'Column 3',
			),

			/*
			 * Column 4
			*/
			array(
				'label' => 'Title',
				'id' => 'title4',
				'std' => 'Basic',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 4',
			),
			array(
				'label' => 'Content',
				'id' => 'content4',
				'std' => '1GB Disk Space
				    10GB Monthly Bandwidth
				    2 Email Accounts
				    Unlimited subdomains
				',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 4',
			),
			array(
				'label' => 'Currency',
				'id' => 'currency4',
				'std' => '$',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 4',
			),
			array(
				'label' => 'Price',
				'id' => 'price4',
				'std' => '9',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 4',
			),
			array(
				'label' => 'Price per month/year',
				'id' => 'price_per4',
				'std' => 'per month',
				'type' => 'text',
				'section' => 'Column 4',
			),
			array(
				'label' => 'Button Text',
				'id' => 'buttontext4',
				'std' => 'Sign up',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 4',
			),
			array(
				'label' => 'Button Link URL',
				'id' => 'button_link4',
				'std' => '#',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 4',
			),
			array(
				'label' => 'Highlights',
				'id' => 'highlights4',
				'std' => '0',
				'type' => 'select',
				'section' => 'styling',
				'tab'		=> 'Column 4',
				'choices' => array(
					array(
						'label' => 'No',
						'value' => '0'
					),
					array(
						'label' => 'Yes',
						'value' => '1'
					),
				)
			),
			array(
				'label' => 'Text Highlights',
				'id' => 'text_highlight4',
				'std' => 'Basic',
				'type' => 'text',
				'section' => 'Column 4',
			),
		);

		$dslc_options = array_merge( $dslc_options, $this->shared_options('animation_options') );
		
    	// Return the array
    	return apply_filters( 'dslc_module_options', $dslc_options, $this->module_id );

    }
 
 	// Module Output
    function output( $options ) {

    	global $dslc_active;
    	
		if ( $dslc_active && is_user_logged_in() && current_user_can( DS_LIVE_COMPOSER_CAPABILITY ) )
			$dslc_is_admin = true;
		else
			$dslc_is_admin = false;
		
		//REQUIRED
		$this->module_start( $options );

	?>
	
	<div class="pricing-table">
		<?php if($options['columns']==4){ ?>
			<?php for($i=1; $i<5; $i++){ ?>
				<div class="one_fourth<?php if($i==4){ echo ' last'; } ?>">
		        	<div class="plan<?php if($options['highlights'.$i]==1){ echo ' most-popular'; } ?>">
		            	<h3><?php echo $options['title'.$i]; ?><span><?php echo $options['currency'.$i].$options['price'.$i]; ?></span></h3>
						<ul>
							<?php 
								$content = stripcslashes( $options['content'.$i] );
								$items = preg_split( '/\r\n|\r|\n/', $content );

								$output = '';
								foreach($items as $item){
									$item = trim($item);
									$text_str = explode(" ", $item);
									$text_top = $text_str[0];
									$text_str[0] = "";
									$text_end = implode(" ", $text_str);
									$output .= '<li><b>'.$text_top.'</b>' . htmlspecialchars_decode( $text_end ) . '</li>';
								}
								
								echo $output;
							?>
						</ul>
						<a href="<?php echo $options['button_link'.$i]; ?>" class="but_signup"><?php echo $options['buttontext'.$i] ?></a>
		            </div>
		        </div><!-- end plan -->
		    <?php } ?>
		<?php } else { ?>
			<?php for($i=1; $i<4; $i++){ ?>
				<div class="one_third<?php if($i==3){ echo ' last'; } ?>">
		        	<div class="plan<?php if($options['highlights'.$i]==1){ echo ' most-popular'; } ?>">
		            	<h3><?php echo $options['title'.$i]; ?><span><?php echo $options['currency'.$i].$options['price'.$i]; ?></span></h3>
						<ul>
							<?php 
								$content = stripcslashes( $options['content'.$i] );
								$items = preg_split( '/\r\n|\r|\n/', $content );

								$output = '';
								foreach($items as $item){
									$item = trim($item);
									$text_str = explode(" ", $item);
									$text_top = $text_str[0];
									$text_str[0] = "";
									$text_end = implode(" ", $text_str);
									$output .= '<li><b>'.$text_top.'</b>' . htmlspecialchars_decode( $text_end ) . '</li>';
								}
								
								echo $output;
							?>
						</ul>
						<a href="<?php echo $options['button_link'.$i]; ?>" class="but_signup"><?php echo $options['buttontext'.$i] ?></a>
		            </div>
		        </div><!-- end plan -->
		    <?php } ?>
		<?php } ?>
	</div>
	<div class="clearfix"></div>
	<?php
    	// REQUIRED
    	$this->module_end( $options );

    }
 
}