<?php

/**
 *
 * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/gpl-3.0.txt
 */

function urbanews_get_module_1($show_label_option, $custom_label, $truncate_title = false, $catID = false) {

	$html = '';
	$innerLeft = '';
	$innerRight = '';
	
	$show_label = ( $show_label_option == true && ( is_numeric($catID) || $custom_label ) ) ? true : false;
	$module_label = ( $custom_label ) ? $custom_label : get_cat_name($catID);
	$post_blocks_additional_css = ( $truncate_title == true ) ? ' post-blocks-truncate-post-titles' : '';

	$args = array(
		'post_type' => 'post',
		'posts_per_page' => 5,
	);

	if ( is_numeric($catID) ) :
		$args['cat'] = $catID;
	endif;

	$query = new WP_Query($args);

	if ( $query->have_posts() ) :

		$innerLeft = '';
		$innerRight = '';
		
		while ( $query->have_posts() ) : $query->the_post();
			
			global $post;
			
			if( 0 == $query->current_post ) {
			
				$innerLeft .= urbanews_get_main_article($post->ID, 'urbanews_post_blocks_large', 'placeholder-700x611.jpg');
			
			} else {
				
				$innerRight .= urbanews_get_small_article($post->ID);
			
			}
			
		endwhile;
				
	endif;
	wp_reset_postdata();

	$html .= '<div class="news_container module-1 layout-1' . esc_attr($post_blocks_additional_css) . '">';

		$html .= ( $show_label == true) ? '<h4 class="title"><span>' . esc_html($module_label) . '</span></h4>' : '';

		$html .= '<div class="clear"></div>';
		
		$html .= '<div class="news_left_col">';

			$html .= $innerLeft;

		$html .= '</div>';

		$html .= '<div class="news_right_col">';

			$html .= $innerRight;

		$html .= '</div>';

		$html .= '<div class="clear"></div>';

	$html .= '</div>';
	
	return $html;

}

?>