<?php

$temp =& $osDB->getAll( 'SELECT * FROM ! where enabled = ? order by date desc limit !', array( STORIES_TABLE, 'Y' , $config['stories_count']) );

$index = 0;

$data = array();

foreach( $temp as $index => $row ) {

	$row1 =& $osDB->getRow( 'SELECT * FROM ! where id= ?', array( USER_TABLE, $row[sender] ) );

	$row[ 'username' ] = $row1['username'];

	if (strlen($row['text']) > $config['length_story'] ) {

		$arrtext = explode( ' ', $row['text'], $config['length_story'] + 1);

		$arrtext[$config['length_story']] = '';

		$row['text'] = trim(implode( ' ', $arrtext)) . '...';

	}

	$row['date'] = date(get_lang('DISPLAY_DATE_FORMAT'), $row['date'] );

	$data[ $index ] = $row;

	$index++;
}


$t->assign ( 'story_data', $data );

unset($data, $temp, $row);

?>