<?php do_action( 'bp_before_forums_loop' ); ?>

<?php
global $bp_forum_topics, $forum_template;
if( ! $bp_forum_topics ) $bp_forum_topics = bp_has_forum_topics( bp_ajax_querystring( 'forums' ) );
?>

<?php if ( $bp_forum_topics ) : ?>

	<?php do_action( 'bp_before_directory_forums_list' ); ?>

	<table class="forum">
		<tbody>

			<?php while ( bp_forum_topics() ) : bp_the_forum_topic(); ?>

			<tr class="<?php bp_the_topic_css_class(); ?>">
				<td class="td-title">
					<?php bp_the_topic_poster_avatar( 'width=35&height=35' ) ?>

					<a class="topic-title" href="<?php bp_the_topic_permalink(); ?>" title="<?php bp_the_topic_title(); ?> - <?php _e( 'متابعه', 'MCL' ); ?>">
						<?php bp_the_topic_title(); ?>
					</a>

					<p class="topic-meta">
						<span class="topic-by"><?php printf( __( 'بواسطه : %1$s', 'MCL' ), bp_get_the_topic_poster_name() ); ?></span>,
						<span class="topic-on"><?php printf( __( 'فى : %1$s', 'MCL' ), date( 'm.d.Y', strtotime( bp_get_the_topic_time() ) ) ); ?></span>
					</p>
				</td>

				<td class="td-group">
					<?php if ( !bp_is_group_forum() ) : ?>

						<p class="topic-meta">
							<?php bp_the_topic_object_avatar( 'width=35&height=35' ) ?>

							<span><?php _e( 'اضيفت فى ', 'MCL' ) ?></span>
						</p>

						<p class="topic-meta">
							<span>
							<?php
								$topic_in = '<a href="' . bp_get_the_topic_object_permalink() . '" title="' . bp_get_the_topic_object_name() . '">' . bp_get_the_topic_object_name() .'</a>';

								printf( __( '%1$s', 'MCL' ), $topic_in );
							?>
							</span>

						</p>

					<?php endif; ?>
				</td>

				<td class="td-freshness">
					<?php bp_the_topic_last_poster_avatar( 'width=35&height=35' ); ?>

					<p class="topic-meta">
						<span class="freshness-author">
							<?php _e( 'بواسطه &middot; ', 'MCL' ); bp_the_topic_last_poster_name(); ?>
						</span>
					</p>
				</td>

				<td class="td-postcount">
					<a href="<?php bp_the_topic_permalink(); ?>">
						<?php printf( _n( "<b>%d</b> رد", "<b>%d</b> رد", bp_get_the_topic_total_posts() ), bp_get_the_topic_total_posts() ); ?>
					</a>
				</td>

				<?php do_action( 'bp_directory_forums_extra_cell' ); ?>

			</tr>

			<?php do_action( 'bp_directory_forums_extra_row' ); ?>

			<?php endwhile; ?>

		</tbody>
	</table>

	<?php do_action( 'bp_after_directory_forums_list' ); ?>

	<div class="item-list-tabs for-bottom ">
		<p class="pagination fl"><?php bp_forum_pagination(); ?></p>
		<p class="pages-count fr"><?php printf( __( 'الصفحه %d من اصل %d', 'MCL' ), isset( $_GET['upage'] ) ? $_GET['upage'] : 1, ceil( $forum_template->total_topic_count / 21 ) ) ?></p>
	</div>

<?php else: ?>

	<div id="message" class="info">
		<p><?php _e( 'عفوا ,, لا يوجد مناقشات حاليه.', 'MCL' ); ?></p>
	</div>

<?php endif; ?>

<?php do_action( 'bp_after_forums_loop' ); ?>
