<?php

/****************************************/
// ИНФОРМАЦИЯ:
// ==== Форум: LogicBoard
// ==== Автор: Никита Курдин (ShapeShifter)
// ==== Copyright © Никита Курдин Игоревич 2011
// ==== Данный код защищен авторскими правами
// ==== Официальный сайт: http://logicboard.ru

/****************************************/

if (! defined('LogicBoard') )
{
	@include '../../logs/save_log.php';
	exit ( "Error, wrong way to file.<br><a href=\"/\">Go to main</a>." );
}

class LB_topics
{
	PUBLIC $query = "";

	function Data_out($template, $template_save, $topic_nav = false)
	{
        global $tpl, $DB, $cache_config, $member_id, $cache_group, $cache_forums, $i, $j, $onl_limit, $link_on_post;

        $lang_c_topics_out = language_forum ("board/class/topics_out");

        $tpl->load_template ( $template );
        
        while ( $row = $DB->get_row($this->query) )
        {
            $i ++;
            $j ++;
        
            $tpl->tags('{author}', $row['member_name_open']);
        
            if ($row['member_id_open'] == 0)
            {
                $tpl->tags_blocks("guest_topic");
                $tpl->tags_blocks("member_topic", false);
            }
            else
            {
                $tpl->tags_blocks("guest_topic", false);
                $tpl->tags_blocks("member_topic");
                $tpl->tags("{author_link}", profile_link($row['member_name_open'], $row['member_id_open']));
            }
            
            $tpl->tags('{title}', $row['title']);
            
            if ($row['description'])
                $tpl->tags('{description}', htmlspecialchars($row['description']));
            else
                $tpl->tags('{description}', htmlspecialchars($row['title']));
                
            if ($topic_nav)
            {
                $tpl->tags('{forum}', $cache_forums[$row['forum_id']]['title']);
                $tpl->tags('{forum_link}', forum_link($row['forum_id']));
                $tpl->tags_blocks("full_link");
            }
            else
                $tpl->tags_blocks("full_link", false);
            
            $tpl->tags('{views}', $row['views']);
            
            if ($row['status'] == "closed")
            {
                $tpl->tags('{ico}', "ico-fold-closed");
                $tpl->tags('{alt_topic}', $lang_c_topics_out['close']);
            }
            else
            {
                if (!$row['poll_id'])
                {
                    if ($row['post_num'] >= intval($cache_config['topic_hot']['conf_value']))
                    {
                        if (member_topic_read($row['id'], $row['date_last']))
                            $tpl->tags('{ico}', "ico-fold-hot-empty");
                        else   
                            $tpl->tags('{ico}', "ico-fold-hot");
                        $tpl->tags('{alt_topic}', $lang_c_topics_out['hot']);
                    }
                    else
                    {
                        if (member_topic_read($row['id'], $row['date_last']))
                            $tpl->tags('{ico}', "ico-fold-open-empty");
                        else
                            $tpl->tags('{ico}', "ico-fold-open");
                        $tpl->tags('{alt_topic}', $lang_c_topics_out['simple']);    
                    }
                }
                else
                {
                    if (member_topic_read($row['id'], $row['date_last']))
                        $tpl->tags('{ico}', "ico-fold-vote-empty");
                    else
                        $tpl->tags('{ico}', "ico-fold-vote");
                    $tpl->tags('{alt_topic}', $lang_c_topics_out['poll']); 
                }
            }
            
            if($row['post_hiden'] AND forum_options_topics($row['forum_id'], "hideshow"))
            {
                $tpl->tags('{post_hiden}', $row['post_hiden']);
                $tpl->tags_blocks("un_hide_post", false);
                $tpl->tags_blocks("hide_post");
            }
            else
            {
                $tpl->tags_blocks("un_hide_post");
                $tpl->tags_blocks("hide_post", false);
            }
            
            if($row['fixed'])
                $tpl->tags_blocks("fixed");
            else
                $tpl->tags_blocks("fixed", false);
            
            if (forum_options_topics($id))
                $tpl->tags_blocks("moder_line");
            else
                $tpl->tags_blocks("moder_line", false);
                
            if ($row['hiden'])
                $tpl->tags_blocks("hiden");
            else
                $tpl->tags_blocks("hiden", false);
            
            $tpl->tags('{answers}', $row['post_num']);
            $tpl->tags('{date}', formatdate($row['date_last']));
            $tpl->tags('{topic_id}', $row['id']);
            $tpl->tags('{last_author}', $row['member_name_last']);
            
            if ($row['last_post_member'] == 0)
            {
                $tpl->tags_blocks("guest_post");
                $tpl->tags_blocks("member_post", false);  
            }
            else
            {
                $tpl->tags_blocks("guest_post", false);
                $tpl->tags_blocks("member_post");
                $tpl->tags('{last_author_link}', profile_link($row['member_name_last'], $row['last_post_member']));
            }
            
            $tpl->tags('{link}', topic_link($row['id']));
            $tpl->tags('{link_last}', topic_link($row['id'], true));
            $tpl->tags('{link_hide}', topic_link($row['id'], "", true));

            $tpl->compile($template_save);
        }
           
        $DB->free();    
        $tpl->clear();
        
        $this->clear();
	}

	function clear()
	{
        unset($this->query);
		$this->query = "";
	}
}
?>