<?php 

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

class Ainex_Pricing_Hosting extends DSLC_Module {
 		
 	// Module Attributes
    var $module_id = 'Ainex_Pricing_Hosting';
    var $module_title = 'Pricing Hosting';
    var $module_icon = 'dollar';
    var $module_category = 'Ainex - Pricing Table';
 
 	// Module Options
    function options() { 
				
    	// The options array
    	$dslc_options = array(
			array(
				'label' => 'Pricing Hosting - Title',
				'id' => 'title',
				'std' => 'Standard hosting|Plan One|Plan Two|Plan Three',
				'type' => 'textarea',
			),
			array(
				'label' => 'Content',
				'id' => 'content',
				'std' => 'Unlimited Bandwidth|Y|Y|Y
				    Unlimited Domain Hosting|Y|Y|Y
				    Free Domain Name Registration*|1 Year|1 Year|1 Year
				    Dedicated IP Addresses|Y|Y|Y
				    Data Transfer|Y|Y|Y
				    Support International Domain Names|N|Y|Y
				    Database Support|Y|Y|Y
				    Ecommerce Ready|N|N|Y
				    Parked Domains|N|N|N
				    Sub Domains|2|5|10
				    Web File Manager|Y|Y|Y
				    Log Files|Y|Y|Y
				    Website Statistics|N|Y|Y
				    Site Statistics|Y|Y|Y
				    Custom Cronjobs|N|N|N
				    FREE Ad Coupons|N|Y|Y
				    FREE 24/7 Support|Y|Y|Y
				    Account Control Panel|Y|Y|Y',
				'type' => 'textarea',
			),
			array(
				'label' => 'Price Details',
				'id' => 'sub_title',
				'std' => 'Price Details',
				'type' => 'textarea',
			),
			array(
				'label' => 'Content Currency',
				'id' => 'content_currency',
				'std' => '$|$|$',
				'type' => 'textarea',
			),
			array(
				'label' => 'Content Price',
				'id' => 'content_price',
				'std' => '1.99|2.99|3.99',
				'type' => 'textarea',
			),
			array(
				'label' => 'Content Per Month',
				'id' => 'content_per_month',
				'std' => 'm|m|m',
				'type' => 'textarea',
			),
			array(
				'label' => 'Content Button',
				'id' => 'content_button',
				'std' => 'Order Now|Order Now|Order Now',
				'type' => 'textarea',
			),
			array(
				'label' => 'Content Link',
				'id' => 'content_link',
				'std' => '#|#|#',
				'type' => 'textarea',
			),
		);

		$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 );

		$text_title 	 = explode("|", $options['title']);
		$text_currency = explode("|", $options['content_currency']);
		$text_price 	 = explode("|", $options['content_price']);
		$text_per_month= explode("|", $options['content_per_month']);
		$text_button   = explode("|", $options['content_button']);
		$text_link 	 = explode("|", $options['content_link']);
	?>
		<div class="hosting_page_plan_main">
            <div class="hosting_page_plan first">
            	<div class="title"><?php echo $text_title[0]; ?></div>
                <div class="cont-list">
                	<ul>
                		<?php
                			$content = stripcslashes( $options['content'] );
							$items   = preg_split( '/\r\n|\r|\n/', $content );

							$output  = '';
							foreach($items as $item){
								$extract = explode("|", $item);
								$output .= '<li>' . htmlspecialchars_decode( $extract[0] ) . '</li>';
							}
							echo $output;
                		?>
                    </ul>
                </div>
                <div class="ordernow"><h4><?php echo $options['sub_title']; ?></h4></div>
            </div><!-- end section -->

            <div class="hosting_page_plan">
            	<div class="title"><?php echo $text_title[1]; ?></div>
                <div class="cont-list">
                	<ul>
                    	<?php
                			$content = stripcslashes( $options['content'] );
							$items   = preg_split( '/\r\n|\r|\n/', $content );

							$output  = '';
							foreach($items as $item){
								$extract = explode("|", $item);
								switch ($extract[1]) {
									case 'Y':
										$output .= '<li><i class="fa fa-check fa-lg green"></i></li>';
									break;
									case 'N':
										$output .= '<li><i class="fa fa-times fa-lg gray"></i></li>';
									break;
									default:
										$output .= '<li>' . htmlspecialchars_decode( $extract[1] ) . '</li>';
									break;
								}
							}
							echo $output;
                		?>
                    </ul>
                </div>
                <div class="ordernow"> <span class="price"><?php echo $text_currency[0].$text_price[0]; ?><i>/<?php echo $text_per_month[0] ?></i></span> <a href="<?php echo $text_link[0]; ?>" class="ordernow_but"><?php echo $text_button[0]; ?></a></div>
            </div><!-- end section -->

            <div class="hosting_page_plan">
            	<div class="title"><?php echo $text_title[2]; ?></div>
                <div class="cont-list">
                	<ul>
                    	<?php
                			$content = stripcslashes( $options['content'] );
							$items   = preg_split( '/\r\n|\r|\n/', $content );

							$output  = '';
							foreach($items as $item){
								$extract = explode("|", $item);
								switch ($extract[2]) {
									case 'Y':
										$output .= '<li><i class="fa fa-check fa-lg green"></i></li>';
									break;
									case 'N':
										$output .= '<li><i class="fa fa-times fa-lg gray"></i></li>';
									break;
									default:
										$output .= '<li>' . htmlspecialchars_decode( $extract[2] ) . '</li>';
									break;
								}
							}
							echo $output;
                		?>
                    </ul>
                </div>
                <div class="ordernow"> <span class="price"><?php echo $text_currency[1].$text_price[1]; ?><i>/<?php echo $text_per_month[1] ?></i></span> <a href="<?php echo $text_link[1]; ?>" class="ordernow_but"><?php echo $text_button[1]; ?></a></div>
            </div><!-- end section -->

            <div class="hosting_page_plan">
            	<div class="title"><?php echo $text_title[3]; ?></div>
                <div class="cont-list">
                	<ul>
                    	<?php
                			$content = stripcslashes( $options['content'] );
							$items   = preg_split( '/\r\n|\r|\n/', $content );

							$output  = '';
							foreach($items as $item){
								$extract = explode("|", $item);
								switch ($extract[3]) {
									case 'Y':
										$output .= '<li><i class="fa fa-check fa-lg green"></i></li>';
									break;
									case 'N':
										$output .= '<li><i class="fa fa-times fa-lg gray"></i></li>';
									break;
									default:
										$output .= '<li>' . htmlspecialchars_decode( $extract[3] ) . '</li>';
									break;
								}
							}
							echo $output;
                		?>
                    </ul>
                </div>
                <div class="ordernow"> <span class="price"><?php echo $text_currency[2].$text_price[2]; ?><i>/<?php echo $text_per_month[2] ?></i></span> <a href="<?php echo $text_link[2]; ?>" class="ordernow_but"><?php echo $text_button[2]; ?></a></div>
            </div><!-- end section -->
    	</div>
		<div class="clearfix"></div>

	<?php
    	// REQUIRED
    	$this->module_end( $options );

    }

}