<?php
add_action('dslc_hook_register_modules',
    create_function('', 'return dslc_register_module( "Ainex_Contact" );')
);

class Ainex_Contact extends DSLC_Module {

 	// Module Attributes
    var $module_id = 'Ainex_Contact';
    var $module_title = 'Contact Form7';
    var $module_icon = 'envelope-o';
    var $module_category = 'Ainex - Posts';


 	// Module Options
    function options() {
    	// Load contact form 7
    	$args2 = array(
			'post_type' => 'wpcf7_contact_form',
		);
		$ctf7s = get_posts($args2);
		$ts_ctf7 = array();
		$ts_ctf7[] = array(
			'value' => '',
			'label' => 'Select contact form'
		);
		foreach($ctf7s as $ctf7) {
			$ts_ctf7[] = array(
				'value' => $ctf7->ID,
				'label' => $ctf7->post_title
			);
		};
    	// The options array
    	$dslc_options = array(
			array(
                'label' => 'Contact Form7 - Select',
                'id' => 'contact_form7_id',
                'std' => '',
                'type' => 'select',
                'choices' => $ts_ctf7
            ),
		);
		$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 );

		$services_active = '';
		if ( $dslc_active )
			$services_active .= 'helight';

		if($options['contact_form7_id']):
			$sc = '[contact-form-7 id="'.$options['contact_form7_id'].'" title="Contact form 7 '.$options['contact_form7_id'].'"]';
		?>
			<div class="contact_form7">
				<?php echo do_shortcode($sc); ?>
			</div>
		<?php else: ?>
			<div class="dslc-notification dslc-red"><?php echo __( 'No data has been set yet, edit the module to set one.', 'themestudio' ); ?></div>
		<?php endif; ?>
		<div class="clearfix"></div>

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

    }

}