* but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 */
$mainposts_per_page = get_config('mainposts_per_page');
$CoreNews = new CoreNews();
$num_items = $CoreNews->news_count();
// inicjowanie funkcji stronnicuj�cej wpisy
$pagination = pagination($CoreRewrite->pagination($rewrite), $mainposts_per_page, $num_items);
// definiujemy blok dynamiczny szablonu
$ft->define_dynamic('note_row', 'rows');
$ft->define_dynamic('cat_row', 'rows');
$CoreNews->news_list(null);
if (count($CoreNews->news)) {
    foreach ($CoreNews->news as $news) {
        $id = $news->get_id();
        list_assigned_categories($id);
        $text = show_me_more($news->get_text());
        $text = preg_replace("/\\[code:\"?([a-zA-Z0-9\\-_\\+\\#\$\\%]+)\"?\\](.*?)\\[\\/code\\]/sie", "highlighter('\\2', '\\1')", $text);
        $ft->assign(array('DATE' => date($date_format, $news->get_timestamp()), 'NEWS_TITLE' => $news->get_title(), 'NEWS_TEXT' => $text, 'NEWS_AUTHOR' => $news->get_author(), 'NEWS_ID' => $id, 'NEWS_CATEGORY' => '', 'PERMA_LINK' => $CoreRewrite->permanent_news($id, $rewrite), 'PAGINATED' => !empty($pagination['page_string']) ? true : false, 'STRING' => $pagination['page_string']));
        get_comments_link($news->get_comments_allow(), 0, $id);
        //TODO
        $ft->assign('RETURN', '');
        $ft->parse('MAIN', '.note_row');
    }
} else {
    // Obs�uga b��du, kiedy w bazie danych nie ma jeszcze �adnego wpisu
    $ft->assign(array('QUERY_FAILED' => $i18n['main_view'][1], 'STRING' => '', 'PAGINATED' => false, 'MOVE_BACK' => false, 'MOVE_FORWARD' => false));
    $ft->parse('MAIN', '.query_failed');
}
$ft->define_dynamic("note_row", "rows");
$ft->define_dynamic("cat_row", "rows");
// Sprawdzamy, czy w bazie danych s± ju¿ jakie¶ wpisy
if ($db->num_rows() > 0) {
    while ($db->next_record()) {
        $date = date($date_format, $db->f("date"));
        $title = $db->f("title");
        $text = $db->f("text");
        $author = $db->f("author");
        $id = $db->f("id");
        $c_id = $db->f("c_id");
        $image = $db->f("image");
        $comments_allow = $db->f("comments_allow");
        $comments = $db->f("comments");
        list_assigned_categories($id);
        $perma_link = (bool) $rewrite ? sprintf('1,%s,1,item.html', $id) : 'index.php?p=1&id=' . $id;
        $text = highlighter($text, '<code>', '</code>');
        $text = show_me_more($text);
        $ft->assign(array('DATE' => $date, 'NEWS_TITLE' => $title, 'NEWS_TEXT' => $text, 'NEWS_AUTHOR' => $author, 'NEWS_ID' => $id, 'NEWS_CATEGORY' => $c_id, 'PERMA_LINK' => $perma_link, 'PAGINATED' => !empty($pagination['page_string']) ? true : false, 'STRING' => $pagination['page_string']));
        get_comments_link($comments_allow, $comments, $id);
        get_image_status($image, $id);
        $ft->assign('RETURN', '');
        $ft->parse('MAIN', ".note_row");
    }
    // Parsowanie elementów poza DYNAMIC BLOCK :: fixed
    $ft->parse('MAIN', "rows");
} else {
    // Obs³uga b³êdu, kiedy w bazie danych nie ma jeszcze ¿adnego wpisu
    $ft->assign(array('QUERY_FAILED' => $i18n['main_view'][1], 'STRING' => '', 'PAGINATED' => false, 'MOVE_BACK' => false, 'MOVE_FORWARD' => false));
    $ft->parse('MAIN', ".query_failed");
}