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

class Ainex_Twitter_Post extends DSLC_Module {

 	// Module Attributes
    var $module_id = 'Ainex_Twitter_Post';
    var $module_title = 'Twitter';
    var $module_icon = 'user';
    var $module_category = 'Ainex - Posts';


 	// Module Options
    function options() {
    	global $ts_animation_style;
    	// The options array
    	$dslc_options = array(
			array(
				'label' => 'Number twitter',
				'id' => 'number',
				'std' => '1',
				'type' => 'text',
				'section' => 'functionality',
			),
			array(
				'label' => __( 'Margin Bottom', 'dslc_string' ),
				'id' => 'css_margin_bottom',
				'std' => '0',
				'type' => 'slider',
				'refresh_on_change' => false,
				'affect_on_change_el' => '.features_sec05',
				'affect_on_change_rule' => 'margin-bottom',
				'section' => 'styling',
				'ext' => 'px',
			),

			/*
			 * Animation Style
			*/
			array(
				'label' => __( 'Animation Style', 'dslc_string' ),
				'id' => 'css_animation_class',
				'std' => 'fadeInDown',
				'type' => 'select',
				'choices' => $ts_animation_style,
				'section' => 'styling',
				'tab' => 'Ainex Animation',
			),
			array(
				'label' => __( 'Animation Duration', 'dslc_string' ),
				'id' => 'animation_duration',
				'std' => '',
				'type' => 'slider',
				'section' => 'styling',
				'tab' => 'Ainex Animation',
				'refresh_on_change' => false,
				'affect_on_change_el' => '',
				'affect_on_change_rule' => '',
				'ext' => 's',
				'min' => 0,
				'max' => 10,
				'increment' => 0.1,
			),
			array(
				'label' => __( 'Animation Delay', 'dslc_string' ),
				'id' => 'animation_delay',
				'std' => '',
				'type' => 'slider',
				'section' => 'styling',
				'tab' => 'Ainex Animation',
				'refresh_on_change' => false,
				'affect_on_change_el' => '',
				'affect_on_change_rule' => '',
				'ext' => 's',
				'min' => 0,
				'max' => 10,
				'increment' => 0.1,
			),
		);
		$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['number']):
			$number = (int)$options['number'];
			$tweets = getTweets($number);
		?>
			<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
			<div class="features_sec05">
				<div class="container">
				    <div class="twitter_feeds">
				    	<ul class="slides">
					    	<?php foreach($tweets as $tweet){ ?>
						    	<li>
						          	<a href="https://twitter.com/<?php echo get_option('tdf_user_timeline'); ?>" target="_blank"><strong><?php echo get_option('tdf_user_timeline'); ?></strong></a>: <?php echo $tweet['text']; ?><br />
							        <small>.
								        <a href="<?php echo 'https://twitter.com/'.get_option('tdf_user_timeline').'/status/'.$tweet['id_str']; ?>"><?php echo human_time_diff( strtotime($tweet['created_at']), current_time('timestamp') ) . ' ago'; ?></a> .
								        <a href="https://twitter.com/intent/tweet?in_reply_to=<?php echo $tweet['id_str']; ?>"><?php echo __('reply', 'themestudio'); ?></a> .
							            	<a href="https://twitter.com/intent/retweet?tweet_id=<?php echo $tweet['id_str']; ?>"><?php echo __('retweet', 'themestudio'); ?></a> .
							            	<a href="https://twitter.com/intent/favorite?tweet_id=<?php echo $tweet['id_str']; ?>"><?php echo __('favorite', 'themestudio'); ?></a>
							        </small>
							    </li>
					        <?php } ?>
				        </ul>
				    </div>
				</div>
			</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 );

    }

}