<?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 citymag_get_module_2($show_label_option, $custom_label , $truncate_title = false, $catID = false) {

	$html = '';
	$inner = '';

	$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' => 8,
	);

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

	$query = new WP_Query($args);

	if ( $query->have_posts() ) :

		while ( $query->have_posts() ) : $query->the_post();
		
		global $post;
	
		if ($query->current_post == 4) {
			
			$inner .= '</div>';
			$inner .= '<div class="news_right_col">';
		
		}
	
		if( 
			$query->current_post == 0 || 
			$query->current_post == 4  
		) {
	
			$inner .= citymag_get_main_article($post->ID, 'citymag_post_blocks_medium');
	
		} else {
						
			$inner .= citymag_get_small_article($post->ID);
	
		}
	
		endwhile;
	
	endif;
	wp_reset_postdata();

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

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

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

			$html .= $inner;

		$html .= '</div>';

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

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

}

?>