<?php

/*
=================================================================
Bullet Energy - by White-Master 
-----------------------------------------------------------------
http://white-master.ru/
-----------------------------------------------------------------
Copyright (c) 2011 White-Master
=================================================================
Данный код защищен авторскими правами
=================================================================
Файл: main_viewer.class.php
=================================================================
*/
class BulletEnergyView extends BulletEnergy
{
   public $tpl = null;
   private $DIR_TPL = '';
   private $id = 0;
   private $userID = '';
   public $tplIsCompile = array();
   public function __construct()
   {
      if(!class_exists('dle_template')) {
         include_once (ROOT_DIR . '/engine/classes/templates.class.php');
      }
      $this->tpl = new dle_template;
      $this->tpl->dir = ROOT_DIR . '/templates/' . parent::$config_dle['skin'] . '/bullet_energy/';
      $this->DIR_TPL = parent::$config_dle['http_home_url'] . 'templates/' . parent::$config_dle['skin'] . '/bullet_energy/';
      $this->id = parent::$handler->db->safesql(parent::$handler->getInt('id'));
      $this->userID = parent::$handler->db->safesql(parent::$id_member['user_id']);
      $this->tplIsCompile = parent::$handler->checkUrl(parent::$unsigneds);
   }
   public function add_topic($data = '')
   {
      $form .= "<form onsubmit=\"if(document.new_topic.topic_name.value == '' || document.new_topic.message_new_topic.value == ''){BeAlert('<br>" . parent::$modules_lang['error_6'] . "', '" . parent::$modules_lang['information'] . "');return false}\" id = \"new_topic\" name=\"new_topic\" method=\"post\" action=''>";
      $this->tpl->load_template('add_topic.tpl');
      $this->tpl->set('{Bbcode}', $this->get_bb_message('', true, '', 'new_topic', 'message_new_topic', false));
      $this->tpl->set('{Form}', '<textarea id="message_new_topic" name="message_new_topic" onclick="setNewField(this.name,document.getElementById(\'new_topic\'))" rows="15" class="bullet_area"></textarea>');
      $this->tpl->set('{Uploader}', $this->_get_uploader($data));
      if(parent::$handler->ckeckModulesConfig('be_access_topic_new_private')) {
         $this->tpl->set('[paramPrivateTopic]', '');
         $this->tpl->set('[/paramPrivateTopic]', '');
      } else {
         $this->tpl->set_block("'\\[paramPrivateTopic\\](.*?)\\[/paramPrivateTopic\\]'si", '');
      }
      if(parent::$handler->ckeckModulesConfig('be_create_vote')) {
         $this->tpl->set('[vote]', '');
         $this->tpl->set('[/vote]', '');
      } else {
         $this->tpl->set_block("'\\[vote\\](.*?)\\[/vote\\]'si", '');
      }
      $this->tpl->copy_template = $form . $this->tpl->copy_template . '<input name="action" value="add_topic" type="hidden"/></form>';
      $this->tpl->compile('add_topic');
      return $this->tpl->result['add_topic'];
   }
   private function _get_uploader($data = '')
   {
      if(parent::$handler->ckeckModulesConfig('be_upload_img') or parent::$handler->ckeckModulesConfig('be_upload')) {
         if(parent::$handler->ckeckModulesConfig('be_upload')) {
            $ext .= parent::$modules_config['upload_file_type'];
         }
         if(parent::$handler->ckeckModulesConfig('be_upload_img')) {
            $ext .= ', gif, jpg, png, jpe, jpeg';
         }
         if($data) {
            $isData = '';
         } else {
            $isData = 'style="display:none"';
         }
         return '<div id="upload_file_block"><div class="InnertMainBoxUpload"><div class="bottom_upload"><div class="innert_buttm"><input id="file_upload" name="file_upload" type="file" /><span class="access_upload"><ul><li><strong>' . parent::$modules_lang['upload_0'] . '</strong>:' . $ext . '</li><li><strong>' . parent::$modules_lang['upload_1'] . '</strong>: ' . parent::$handler->formatsize(parent::$modules_config['upload_max_size'] * 1024) . '</li></ul></span></div></div><ol ' . $isData . ' id="block_files">' . $data . '</ol></div></div>';
      } else {
         return false;
      }
   }
   public function error_set($title = '', $data = '', $meta = array())
   {
      if($meta) {
         parent::$meta['title'] = $meta[0];
      } elseif(!$meta) {
         parent::$meta['title'] = parent::$modules_lang['error_3'];
      }
      $this->tpl->load_template('info.tpl');
      $this->tpl->set('{title}', $title);
      $this->tpl->set('{error}', $data);
      $this->tpl->compile('info');
      return $this->tpl->result['info'];
   }
   public function setTplAttachmentList($data = array())
   {
      /*Function is modified 04.07.2011 RC 0.1*/
      $option = array('insert' => '', 'name' => '', 'description' => '', 'idFile' => '', 'img' => array());
      if($data['fileType'] == 0) {
         $file = parent::$config_dle['http_home_url'] . "uploads/forum/images/" . $data['fileDateUpload'] . "/{$data['fileName']}";
         if(file_exists(ROOT_DIR . '/uploads/forum/images/' . $data['fileDateUpload'] . '/thumbs/' . $data['fileName'])) {
            $option['img'][] = "<a class=\"mini_img\" href=\"javascript:;MiniImg('{$file}')\">" . parent::$modules_lang['attachment_5'] . "</a>";
         }
         if(file_exists(ROOT_DIR . '/uploads/forum/images/' . $data['fileDateUpload'] . '/' . $data['fileName']) and parent::$modules_config['images_prev_insert']) {
            $option['img'][] = "<a class=\"ful_img\" href=\"javascript:;FullImg('{$file}')\">" . parent::$modules_lang['attachment_6'] . "</a>";
         }
         if(!file_exists(ROOT_DIR . '/uploads/forum/images/' . $data['fileDateUpload'] . '/thumbs/' . $data['fileName'])) {
            $option['img'][] = "<a class=\"ful_img\" href=\"javascript:;FullImg('{$file}')\">" . parent::$modules_lang['attachment_6'] . "</a>";
         }
         $option['insert'] = implode(' - ', $option['img']);
         $option['description'] = '<li class="descrip_file">' . parent::$modules_lang['attachment_7'] . ':</li>';
         $option['name'] = '<a class="name_file" target="_blank" href = "' . $file . '">' . $data['fileNameSiteView'] . '</a>';
      } else {
         $option['insert'] = parent::$modules_lang['attachment_8'];
         $option['name'] = $data['fileNameSiteView'];
      }
      return '<li class="file" id="' . $data['fileDbId'] . '"><div class="BoxInnertList"><span class="' . $data['fileExtensions'] . ' icon">ICO</span>
    <ol class="file_info"><li>' . $option['name'] . '</li>' . $option['description'] . '<li>' . $option['insert'] . '</li></ol><a href ="#" onclick = "DelAttach(\'' . $data['fileDbId'] . '\',\'' . parent::$hash_login . '\'); return false;" class = "delbutton">' . parent::$modules_lang['attachment_9'] . '</a></div></li>';
   }
   /**
    * BulletEnergyView::setTplReplyFull()
    * Метод компиляции шаблона полного ответа в теме.
    * @param mixed $data - массив входных параметров.
    * @param mixed $data[id_parent] - Идентификатор узла в котором находится тема.
    * @param mixed $data[title] - Заголовок темы.
    * @param mixed $data[id] - Идентификатор темы.
    * @param mixed $data[data] - Данные которые ввел пользователь в форме быстрого ответа.
    * @return void
    */
   public function setTplReplyFull($data = array())
   {
      //var_dump($data);
      $this->tpl->load_template('add_message_full.tpl');
      $this->tpl->set('{editor}', $this->get_bb_message(stripcslashes($data['data']), true, '', 'message_add_form', 'message_reply', true));
      $this->tpl->set('{Uploader}', $this->_get_uploader($data['attachment']));
      if(parent::$groups_config[parent::$id_member['user_group']]['be_captha_status']) {
         $this->tpl->set('{captha}', '');
      } else {
         if(parent::$id_member['forum_post_count'] < parent::$modules_config['anti_no']) {
            if(parent::$modules_config['captha_type']) {
               $this->tpl->set('{captha}', '<div id="recaptchaForumBlock"> </div><script type="text/javascript" src="http://www.google.com/recaptcha/api/js/recaptcha_ajax.js"></script><script language="javascript"type="text/javascript">$(function(){Recaptcha.create("' . parent::$modules_config['republic'] . '","recaptchaForumBlock",{theme:"clean",lang:"' . parent::$modules_lang['recapthaLang'] . '"});});</script>');
            } else {
               $question = parent::$question[array_rand(parent::$question)];
               $this->tpl->set('{captha}', '<dl><dt>' . parent::$modules_lang['msg_15'] . $question['question'] . '</dt><dd><input name="question" id="question" type="text" onfocus="if(this.value==\'Введите ответ...\') this.value=\'\';" onblur="if(this.value==\'\') this.value=\'Введите ответ...\';" value="Введите ответ..." autocomplete="off"></dd><input type="hidden" name="question_sec" value="' . $question['id'] . '"></dl>');
            }
         } else {
            $this->tpl->set('{captha}', '');
         }
      }
      $data['error'] = count($data['error']) ? $data['error'] : '';
      $this->tpl->copy_template = $data['error'] . "<form  method=\"post\" name=\"message_add_form\" id=\"message_add_form\" action=\"\">" . $this->tpl->copy_template . "
		<input type=\"hidden\" name=\"topict_id\" id=\"topict_id\" value=\"$data[id]\" /><input type=\"hidden\" name=\"action\"  value=\"add_message\"/></form>";
      $this->tpl->compile('add_message_full');
      return $this->tpl->result['add_message_full'];
   }
   /**
    * BulletEnergyView::static_view()
    * Метод вывода статического шаблона.
    * @param string $title - Заголовок  в теле шаблона.
    * @param string $data - Выводимая информация.
    * @return
    */
   public function static_view($title = '', $data = '')
   {
      $this->tpl->load_template('static.tpl');
      $this->tpl->set('{description}', $title);
      $this->tpl->set('{static}', $data);
      $this->tpl->compile('static');
      return $this->tpl->result['static'];
   }
   public function add_message($data = array())
   {
      $this->tpl->load_template('add_message.tpl');
      $this->tpl->set('{editor}', $this->get_bb_message('', false, 'onkeypress="submitKey(event);"', 'message_add_form', 'message_reply', true));
      if(parent::$groups_config[parent::$id_member['user_group']]['be_captha_status']) {
         $this->tpl->set('{captha}', '');
      } else {
         if(parent::$id_member['forum_post_count'] < parent::$modules_config['anti_no']) {
            if(parent::$modules_config['captha_type']) {
               $this->tpl->set('{captha}', '<div id="recaptchaForumBlock"> </div><script type="text/javascript" src="http://www.google.com/recaptcha/api/js/recaptcha_ajax.js"></script><script language="javascript"type="text/javascript">$(function(){Recaptcha.create("' . parent::$modules_config['republic'] . '","recaptchaForumBlock",{theme:"clean",lang:"' . parent::$modules_lang['recapthaLang'] . '"});});</script>');
            } else {
               $question = parent::$question[array_rand(parent::$question)];
               $this->tpl->set('{captha}', '<dl><dt>' . parent::$modules_lang['msg_15'] . $question['question'] . '</dt><dd><input name="question" id="question" type="text" onfocus="if(this.value==\'Введите ответ...\') this.value=\'\';" onblur="if(this.value==\'\') this.value=\'Введите ответ...\';" value="Введите ответ..." /></dd><input type="hidden" name="question_sec" value="' . $question['id'] . '" /></dl>');
            }
         } else {
            $this->tpl->set('{captha}', '');
         }
      }
      if(parent::$id_member['foto']) {
         $this->tpl->set('{foto}', parent::$config_dle['http_home_url'] . 'uploads/fotos/' . parent::$id_member['foto']);
      } else {
         $this->tpl->set('{foto}', parent::$config_dle['http_home_url'] . 'templates/' . parent::$config_dle['skin'] . '/bullet_energy/images/noavatar.png');
      }
      $this->tpl->copy_template = "<form  method=\"post\" name=\"message_add_form\" id=\"message_add_form\" action=\"\">" . $this->tpl->copy_template . "<input type=\"hidden\" name=\"topict_id\" id=\"topict_id\" value=\"$data[0]\" /><input type=\"hidden\" name=\"action\"  value=\"add_message\"/></form>";
      $this->tpl->compile('add_message');
      return $this->tpl->result['add_message'];
   }
   public function get_bb_message($data = '', $fullMode = false, $keySubmit = '', $formName = '', $selFiled = '', $form = false)
   {
      $option = array();
      if($fullMode) {
         $option['fullBB'] = '<li class="b_code"><span title="' . $lang['bbTitl_18'] . '" onclick="simpletag(\'code\')" id="b_code"></span></li><li class="separator"></li><li><span title="' . $lang['bbTitl_16'] . '" onclick="tag_list(\'ol\')" id="b_ol"></span></li><li><span title="' . $lang['bbTitl_17'] . '" onclick="tag_list(\'list\')" id="b_list"></span></li><li class="separator"></li><li class="b_youtube"><span title="' . $lang['bbTitl_15'] . '" onclick="tag_youtube()" id="b_youtube"></span></li><li class="b_tag_video"><span title="' . $lang['bbTitl_20'] . '" onclick="tag_video()" id="b_tag_video"></span></li><li class="b_tag_audio"><span title="' . $lang['bbTitl_19'] . '" onclick="tag_audio()" id="b_tag_audio"></span></li><li title="' . $lang['bbTitl_21'] . '" class="color_swith"><div id="colorSelector">&nbsp;<div></div></div></li>';
      } else {
         $option['pick'] = '<li class="color_swith"><div onclick="ins_colors(this);" id="colorSelector"></div></li>';
      }
      if($form) {
         $option['form'] = '<textarea rows="9" ' . $keySubmit . ' onclick="setNewField(this.name,document.getElementById(\'' . $formName . '\'))" class="addMsgForm" cols="" name="' . $selFiled . '" id="' . $selFiled . '">' . $data . '</textarea>';
      }
      $i = 0;
      $smiles = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\"><tr>";
      $smilies = explode(",", parent::$config_dle['smilies']);
      foreach ($smilies as $smile) {
         $i++;
         $smile = trim($smile);
         $smiles .= "<td style=\"padding:2px;\" align=\"center\"><a href=\"javascript:;\" onclick=\"dle_smiley(':$smile:'); return false;\"><img style=\"border: none;\" alt=\"$smile\" src=\"" . parent::$config_dle['http_home_url'] . "engine/data/emoticons/$smile.gif\" /></a></td>";
         if($i % 4 == 0)
            $smiles .= "</tr><tr>";
      }
      $smiles .= "</tr></table>";
      $lang = parent::$modules_lang;
      if(parent::$group_user[parent::$id_member['user_group']]['allow_url']) {
         $option['url'] = '<li><span title="' . $lang['bbTitl_10'] . '" onclick="tag_url()" id="b_tag_url"></span></li><li><span title="' . $lang['bbTitl_11'] . '" onclick="tag_leech()" id="b_tag_leech"></span></li>';
      }
      if(parent::$group_user[parent::$id_member['user_group']]['allow_image']) {
         $option['images'] = '<li><span title="' . $lang['bbTitl_12'] . '" onclick="tag_image()" id="b_img"></span></li>';
      }
      $ret = '<div class="form_add_comment"><script type="text/javascript"language="javascript">var selField="message_reply";var fombj=document.forms[\'' . $formName . '\'];</script><div class="bbcode_bullet"><ol class="bbcode_forum"><li><span title="' . $lang['bbTitl_2'] . '" onclick="simpletag(\'b\')" id="b_b"></span></li><li><span title="' . $lang['bbTitl_3'] . '" onclick="simpletag(\'i\')" id="b_i"></span></li><li><span title="' . $lang['bbTitl_4'] . '" onclick="simpletag(\'u\')" id="b_u"></span></li><li><span title="' . $lang['bbTitl_5'] . '" onclick="simpletag(\'s\')" id="b_s"></span></li> <li class="separator"></li><li><span title="' . $lang['bbTitl_7'] . '" onclick="simpletag(\'left\')" id="b_left"></span></li><li><span title="' . $lang['bbTitl_8'] . '" onclick="simpletag(\'center\')" id="b_center"></span></li><li><span title="' . $lang['bbTitl_9'] . '" onclick="simpletag(\'right\')" id="b_right"></span></li><li class="separator"></li><li><span title="' . $lang['bbTitl_6'] . '" onclick="ins_emo(this);" id="b_emo"></span></li>' . $option['url'] . $option['images'] . '<li class="separator"></li><li class="b_hide"><span title="' . $lang['bbTitl_13'] . '" onclick="simpletag(\'hide\')" id="b_hide"></span></li><li><span title="' . $lang['bbTitl_14'] . '" onclick="simpletag(\'quote\')" id="b_quote"></span></li><li><span title="' . $lang['bbTitl_1'] . '" onclick="simpletag(\'spoiler\')" id="b_spoiler"></span></li>' . $option['fullBB'] . $option['pick'] . '</ol><div id="piker_mini" style="display:none">
  <div style="overflow:auto">
    <table width="150" height="100" cellspacing="1" cellpadding="0" border="1" align="center" id="picker">
  <tbody>
    <tr>
      <td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#FFFFFF" id="#FFFFFF"><img width="1" height="1"></td>
      <td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#FFCCCC" id="#FFCCCC"><img width="1" height="1"></td>
      <td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#FFCC99" id="#FFCC99"><img width="1" height="1"></td>
      <td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#FFFF99" id="#FFFF99"><img width="1" height="1"></td>
      <td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#FFFFCC" id="#FFFFCC"><img width="1" height="1"></td>
      <td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#99FF99" id="#99FF99"><img width="1" height="1"></td>
      <td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#99FFFF" id="#99FFFF"><img width="1" height="1"></td>
      <td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#CCFFFF" id="#CCFFFF"><img width="1" height="1"></td>
      <td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#CCCCFF" id="#CCCCFF"><img width="1" height="1"></td>
      <td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#FFCCFF" id="#FFCCFF"><img width="1" height="1"></td>
    </tr>
    <tr>
      <td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#CCCCCC" id="#CCCCCC"><img width="1" height="1"></td>
      <td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#FF6666" id="#FF6666"><img width="1" height="1"></td>
      <td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#FF9966" id="#FF9966"><img width="1" height="1"></td>
      <td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#FFFF66" id="#FFFF66"><img width="1" height="1"></td>
      <td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#FFFF33" id="#FFFF33"><img width="1" height="1"></td>
      <td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#66FF99" id="#66FF99"><img width="1" height="1"></td>
      <td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#33FFFF" id="#33FFFF"><img width="1" height="1"></td>
      <td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#66FFFF" id="#66FFFF"><img width="1" height="1"></td>
      <td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#9999FF" id="#9999FF"><img width="1" height="1"></td>
      <td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#FF99FF" id="#FF99FF"><img width="1" height="1"></td>
    </tr>
    <tr>
      <td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#C0C0C0" id="#C0C0C0"><img width="1" height="1"></td>
      <td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#FF0000" id="#FF0000"><img width="1" height="1"></td>
      <td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#FF9900" id="#FF9900"><img width="1" height="1"></td>
      <td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#FFCC66" id="#FFCC66"><img width="1" height="1"></td>
      <td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#FFFF00" id="#FFFF00"><img width="1" height="1"></td>
      <td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#33FF33" id="#33FF33"><img width="1" height="1"></td>
      <td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#66CCCC" id="#66CCCC"><img width="1" height="1"></td>
      <td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#33CCFF" id="#33CCFF"><img width="1" height="1"></td>
      <td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#6666CC" id="#6666CC"><img width="1" height="1"></td>
      <td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#CC66CC" id="#CC66CC"><img width="1" height="1"></td>
    </tr>
    <tr>
      <td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#999999" id="#999999"><img width="1" height="1"></td>
      <td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#CC0000" id="#CC0000"><img width="1" height="1"></td>
      <td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#FF6600" id="#FF6600"><img width="1" height="1"></td>
      <td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#FFCC33" id="#FFCC33"><img width="1" height="1"></td>
      <td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#FFCC00" id="#FFCC00"><img width="1" height="1"></td>
      <td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#33CC00" id="#33CC00"><img width="1" height="1"></td>
      <td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#00CCCC" id="#00CCCC"><img width="1" height="1"></td>
      <td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#3366FF" id="#3366FF"><img width="1" height="1"></td>
      <td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#6633FF" id="#6633FF"><img width="1" height="1"></td><td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#CC33CC" id="#CC33CC"><img width="1" height="1"></td></tr><tr><td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#666666" id="#666666"><img width="1" height="1"></td><td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#990000" id="#990000"><img width="1" height="1"></td><td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#CC6600" id="#CC6600"><img width="1" height="1"></td><td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#CC9933" id="#CC9933"><img width="1" height="1"></td><td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#999900" id="#999900"><img width="1" height="1"></td><td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#009900" id="#009900"><img width="1" height="1"></td><td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#339999" id="#339999"><img width="1" height="1"></td><td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#3333FF" id="#3333FF"><img width="1" height="1"></td><td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#6600CC" id="#6600CC"><img width="1" height="1"></td><td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#993399" id="#993399"><img width="1" height="1"></td></tr><tr><td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#333333" id="#333333"><img width="1" height="1"></td><td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#660000" id="#660000"><img width="1" height="1"></td><td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#993300" id="#993300"><img width="1" height="1"></td><td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#996633" id="#996633"><img width="1" height="1"></td><td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#666600" id="#666600"><img width="1" height="1"></td><td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#006600" id="#006600"><img width="1" height="1"></td><td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#336666" id="#336666"><img width="1" height="1"></td> <td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#000099" id="#000099"><img width="1" height="1"></td><td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#333399" id="#333399"><img width="1" height="1"></td><td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#663366" id="#663366"><img width="1" height="1"></td></tr><tr><td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#000000" id="#000000"><img width="1" height="1"></td><td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#330000" id="#330000"><img width="1" height="1"></td><td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#663300" id="#663300"><img width="1" height="1"></td><td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#663333" id="#663333"><img width="1" height="1"></td><td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#333300" id="#333300"><img width="1" height="1"></td><td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#003300" id="#003300"><img width="1" height="1"></td><td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#003333" id="#003333"><img width="1" height="1"></td><td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#000066" id="#000066"><img width="1" height="1"></td><td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#330099" id="#330099"><img width="1" height="1"></td><td width="10"  onclick="setColorPicker(this.id); return false;" height="10" bgcolor="#330033" id="#330033"><img width="1" height="1"></td></tr></tbody>
</table></div>
</div>
<div id="bullet_energy_emo" style="display: none;"><div style="overflow: auto;">' . $smiles . '</div></div></div><textarea class="forum_textarea" name="post_text" id="post_text"></textarea>' . $option['form'] . '</div>';
      return $ret;
   }
   /**
    * BulletEnergyView::sub_cat_view()
    * Метод вывода подкатегорий форума внутри родительской категории.
    * @param mixed $data - Массив дочерних узлов.
    * @param integer $mainCatId - Идентификатор родетельского узла.
    * @return
    */
   public function setTplchildTree(array $data = array(), $mainCatId = 0, $accessIsView = array())
   {
      foreach ($data as $category) {
         $this->tpl->load_template('short_category.tpl');
         $option = array();
         if(count(parent::$tree[$category]['treeChild'])) {
            foreach (parent::$tree[$category]['treeChild'] as $idChild) {
               $option['typeChild'] = intval(parent::$tree[$idChild]['tree_type']);
               if(parent::$tree[$idChild]['read'] and $option['typeChild'] != 2 and parent::$logged_is) {
                  $option['childMarkers'] = 'Unread';
                  $option['childMarkersTitle'] = parent::$modules_lang['tree_6'];
               }
               if(!parent::$tree[$idChild]['read'] and $option['typeChild'] != 2 and parent::$logged_is) {
                  $option['childMarkers'] = 'Read';
                  $option['childMarkersTitle'] = parent::$modules_lang['tree_7'];
               }
               if(!parent::$logged_is) {
                  $option['childMarkers'] = 'Unread';
                  $option['childMarkersTitle'] = parent::$modules_lang['tree_6'];
               }
               if(!parent::$tree[$idChild]['read'] and $option['typeChild'] == 2) {
                  $option['childMarkers'] = 'Linck';
                  $option['childMarkersTitle'] = parent::$modules_lang['tree_8'];
               }
               $option['refererChild'] = $option['typeChild'] == 2 ? '<a title="' . htmlspecialchars(parent::$tree[$idChild]['tree_description']) . '" href="' . parent::$tree[$idChild]['tree_type_sub'] . '">' : parent::$handler->linck->cat_linck($idChild, parent::$handler->totranslit(parent::$tree[$idChild]['tree_title'], true, true));
               $option['setTreeChild'] .= '<li title="' . $option['childMarkersTitle'] . '"><span class="childTreeMarkers' . $option['childMarkers'] . '"></span>' . $option['refererChild'] . parent::$tree[$idChild]['tree_title'] . '</a></li>';
            }
            $option['setTreeChild'] = '<ol class="ChildBoxTree">' . $option['setTreeChild'] . '</ol>';
         }
         $last = unserialize(parent::$tree[$category]['tree_last_info']);
         $typeCat = intval(parent::$tree[$category]['tree_type']);
         if(parent::$tree[$category]['tree_last_info']) {
            $this->tpl->set('{lastAutorAvatarLinck}', $last[4]);
            $this->tpl->set('{lastAutorName}', $last[0]);
            $this->tpl->set('{lastTopicName}', $last[2]);
            $this->tpl->set('{lastTopicLinck}', $last[3]);
            $this->tpl->set('[popupUserCard]', parent::$handler->linck->card_user(array($last[0], $last[5])));
            $this->tpl->set('[/popupUserCard]', '</a>');
            $this->tpl->set('{lastMessageDate}', parent::$handler->langdate(parent::$modules_config['time_step_last_message_cat'], $last[1]));
            $this->tpl->set('[LastMessage]', '');
            $this->tpl->set('[/LastMessage]', '');
         } else {
            $this->tpl->set_block("'\\[LastMessage\\](.*?)\\[/LastMessage\\]'si", $info_last);
         }
         $this->tpl->set('{nameTree}', stripslashes(parent::$tree[$category]['tree_title']));
         $this->tpl->set('{description}', stripslashes(parent::$tree[$category]['tree_description']));
         if(parent::$tree[$category]['tree_topic'] > 0) {
            $this->tpl->set('{rssTree}', in_array($category, $accessIsView) ? '<span class="subRss"><a title="' . parent::$modules_lang['tree_10'] . '" href="' . parent::$handler->linck->rssTree($category) . '">rss feed</a></span>' : '');
         } else {
            $this->tpl->set('{rssTree}', '');
         }
         if(parent::$tree[$category]['tree_type'] == '2') {
            $this->tpl->set('[linckTree]', '<a title="' . htmlspecialchars(stripcslashes(parent::$tree[$category]['tree_description'])) . '" href="' . parent::$tree[$category]['tree_type_sub'] . '">');
            $this->tpl->set_block("'\\[blockInfo\\](.*?)\\[/blockInfo\\]'si", "");
            $this->tpl->set('{rssTree}', '');
         } else {
            $this->tpl->set('[linckTree]', parent::$handler->linck->cat_linck(parent::$tree[$category]['tree_id'], parent::$handler->totranslit(parent::$tree[$category]['tree_title'], true, true)));
            $this->tpl->set('[blockInfo]', '');
            $this->tpl->set('[/blockInfo]', '');
         }
         $this->tpl->set('[/linckTree]', '</a>');
         $this->tpl->set('{TreeChild}', $option['setTreeChild']);
         $this->tpl->set('{topic}', parent::$tree[$category]['tree_topic']);
         $this->tpl->set('{message}', parent::$tree[$category]['tree_answer']);
         $this->tpl->set('{treeId}', parent::$tree[$category]['tree_id']);
         if(parent::$tree[$category]['read'] and $typeCat != 2 and parent::$logged_is) {
            $this->tpl->set('{status}', 'unread');
            $this->tpl->set('{statusTitl}', parent::$modules_lang['tree_6']);
         }
         if(!parent::$tree[$category]['read'] and $typeCat != 2 and parent::$logged_is) {
            $this->tpl->set('{status}', 'read');
            $this->tpl->set('{statusTitl}', parent::$modules_lang['tree_7']);
         }
         if(!parent::$logged_is) {
            $this->tpl->set('{status}', 'unread');
            $this->tpl->set('{statusTitl}', parent::$modules_lang['tree_6']);
         }
         if(!parent::$tree[$category]['read'] and $typeCat == 2) {
            $this->tpl->set('{status}', 'linck');
            $this->tpl->set('{statusTitl}', parent::$modules_lang['tree_8']);
         }
         $this->tpl->compile('short_category');
      }
      $this->tpl->load_template('block_category.tpl');
      $this->tpl->set('{description}', '');
      $this->tpl->set('{nameTree}', parent::$modules_lang['tree_1'] . stripslashes(parent::$tree[$mainCatId]['tree_title']));
      $this->tpl->set('{idTree}', parent::$tree[$mainCatId]['tree_id']);
      $this->tpl->set('{contentTree}', $this->tpl->result['short_category']);
      $this->tpl->set('[linckTree]', parent::$handler->linck->cat_linck(parent::$tree[$mainCatId]['tree_id'], parent::$handler->totranslit(parent::$tree[$mainCatId]['tree_title'], true, true)));
      $this->tpl->set('[/linckTree]', '</a>');
      $this->tpl->compile('block_category');
      return $this->tpl->result['block_category'];
   }
   /**
    * BulletEnergyView::list_tree_tpl()
    * Вывод дерева узлов главной страницы форума.
    * @return
    */
   public function setListTreeMainPage($tree = array())
   {
      //11.07.2011
      foreach ($tree as $category) {
         $typeCat = intval($category['tree_type']);
         $status = '';
         if($category['tree_parent_id'] > '0' and $category['tree_approve'] == '1') {
            $this->tpl->load_template('short_category.tpl');
            if(count($category['treeChild'])) {
               foreach ($category['treeChild'] as $idChild) {
                  $category['typeChild'] = intval($tree[$idChild]['tree_type']);
                  if($tree[$idChild]['read'] and $category['typeChild'] != 2 and parent::$logged_is) {
                     $category['childMarkers'] = 'Unread';
                     $category['childMarkersTitle'] = parent::$modules_lang['tree_6'];
                  }
                  if(!$tree[$idChild]['read'] and $category['typeChild'] != 2 and parent::$logged_is) {
                     $category['childMarkers'] = 'Read';
                     $category['childMarkersTitle'] = parent::$modules_lang['tree_7'];
                  }
                  if(!parent::$logged_is) {
                     $category['childMarkers'] = 'Unread';
                     $category['childMarkersTitle'] = parent::$modules_lang['tree_6'];
                  }
                  if(!$tree[$idChild]['read'] and $category['typeChild'] == 2) {
                     $category['childMarkers'] = 'Linck';
                     $category['childMarkersTitle'] = parent::$modules_lang['tree_8'];
                  }
                  $category['refererChild'] = $category['typeChild'] == 2 ? '<a title="' . htmlspecialchars($tree[$idChild]['tree_description']) . '" href="' . $tree[$idChild]['tree_type_sub'] . '">' : parent::$handler->linck->cat_linck($tree[$idChild]['tree_id'], parent::$handler->totranslit(parent::$treePermanent[$idChild]['tree_title'], true, true));
                  $category['setTreeChild'] .= '<li title="' . $category['childMarkersTitle'] . '"><span class="childTreeMarkers' . $category['childMarkers'] . '"></span>' . $category['refererChild'] . $tree[$idChild]['tree_title'] . '</a></li>';
               }
               $category['setTreeChild'] = '<ol class="ChildBoxTree">' . $category['setTreeChild'] . '</ol>';
            }
            $last = unserialize($category['tree_last_info']);
            if($category['tree_last_info']) {
               $this->tpl->set('{lastAutorAvatarLinck}', $last[4]);
               $this->tpl->set('{lastAutorName}', $last[0]);
               $this->tpl->set('{lastTopicName}', $last[2]);
               $this->tpl->set('{lastTopicLinck}', $last[3]);
               $this->tpl->set('[popupUserCard]', parent::$handler->linck->card_user(array($last[0], $last[5])));
               $this->tpl->set('[/popupUserCard]', '</a>');
               $this->tpl->set('{lastMessageDate}', parent::$handler->setDate($last[1]));
               $this->tpl->set('[LastMessage]', '');
               $this->tpl->set('[/LastMessage]', '');
            } else {
               $this->tpl->set_block("'\\[LastMessage\\](.*?)\\[/LastMessage\\]'si", '');
            }
            $this->tpl->set('{nameTree}', stripslashes($category['tree_title']));
            $this->tpl->set('{description}', stripslashes($category['tree_description']));
            if($category['tree_topic'] > 0) {
               $this->tpl->set('{rssTree}', $category['feed'] ? '<span class="subRss"><a title="' . parent::$modules_lang['tree_10'] . '" href="' . parent::$handler->linck->rssTree($category['tree_id']) . '">rss feed</a></span>' : '');
            } else {
               $this->tpl->set('{rssTree}', '');
            }
            if($typeCat == 2) {
               $this->tpl->set('[linckTree]', '<a title="' . htmlspecialchars(stripcslashes($category['tree_description'])) . '" href="' . $category['tree_type_sub'] . '">');
               $this->tpl->set_block("'\\[blockInfo\\](.*?)\\[/blockInfo\\]'si", "");
               $this->tpl->set('{rssTree}', '');
            } else {
               $this->tpl->set('[linckTree]', parent::$handler->linck->cat_linck($category['tree_id'], parent::$handler->totranslit(parent::$treePermanent[$category['tree_id']]['tree_title'], true, true)));
               $this->tpl->set('[blockInfo]', '');
               $this->tpl->set('[/blockInfo]', '');
            }
            $this->tpl->set('[/linckTree]', '</a>');
            $this->tpl->set('{topic}', $category['tree_topic']);
            $this->tpl->set('{message}', $category['tree_answer']);
            $this->tpl->set('{TreeChild}', $category['setTreeChild']);
            $this->tpl->set('{treeId}', $category['tree_id']);
            if($category['read'] and $typeCat != 2 and parent::$logged_is) {
               $this->tpl->set('{status}', 'unread');
               $this->tpl->set('{statusTitl}', parent::$modules_lang['tree_6']);
            }
            if(!$category['read'] and $typeCat != 2 and parent::$logged_is) {
               $this->tpl->set('{status}', 'read');
               $this->tpl->set('{statusTitl}', parent::$modules_lang['tree_7']);
            }
            if(!parent::$logged_is) {
               $this->tpl->set('{status}', 'unread');
               $this->tpl->set('{statusTitl}', parent::$modules_lang['tree_6']);
            }
            if(!$category['read'] and $typeCat == 2) {
               $this->tpl->set('{status}', 'linck');
               $this->tpl->set('{statusTitl}', parent::$modules_lang['tree_8']);
            }
            $this->tpl->compile('short_category_' . $category['tree_parent_id']);
         }
         continue;
      }
      foreach ($tree as $category) {
         $status = '';
         if(intval($category['tree_parent_id']) == 0 and intval($category['tree_approve']) == 1) {
            $this->tpl->load_template('block_category.tpl');
            $this->tpl->set('{description}', stripcslashes($category['tree_description']));
            $this->tpl->set('{nameTree}', stripslashes($category['tree_title']));
            $this->tpl->set('{treeId}', $category['tree_id']);
            $this->tpl->set('[linckTree]', parent::$handler->linck->cat_linck($category['tree_id'], parent::$handler->totranslit(parent::$treePermanent[$category['tree_id']]['tree_title'], true, true)));
            $this->tpl->set('[/linckTree]', '</a>');
            $this->tpl->set('{contentTree}', $this->tpl->result['short_category_' . $category['tree_id']]);
            $this->tpl->compile('block_category');
         }
         continue;
      }
      return $this->tpl->result['block_category'];
   }
   /**
    * BulletEnergyView::setTplPaginator()
    * Метод установки шаблона пагинатора.
    * @param string $prev_linck = Ссыла (-и) на преведущую страницу.
    * @param string $next_linck = Ссыла (-и) на следущую страницу.
    * @param string $rek_page   = Текущая страница.
    * @return
    */
   public function setTplPaginator(array $data = array(), $prev_linck = '', $next_linck = '', $rek_page = '')
   {
      //:TODO: - Рассмотреть передачу через массив.
      //11.07.2011
      //var_dump();
      $this->tpl->load_template('navigation.tpl');
      if($prev_linck) {
         $this->tpl->set('[prevLink]', '<li title="' . parent::$modules_lang['paginator_2'] . '" class="prevLink"><a ' . $data['ajaxPrev'] . ' href="' . $prev_linck . '">');
         $this->tpl->set('[/prevLink]', '</a></li>');
      } else {
         $this->tpl->set_block("'\\[prevLink\\](.*?)\\[/prevLink\\]'si", "");
      }
      if($next_linck) {
         $this->tpl->set('[nextLink]', '<li title="' . parent::$modules_lang['paginator_1'] . '" class="nextLink"><a ' . $data['ajaxNext'] . ' href="' . $next_linck . '">');
         $this->tpl->set('[/nextLink]', '</a></li>');
      } else {
         $this->tpl->set_block("'\\[nextLink\\](.*?)\\[/nextLink\\]'si", "");
      }
      $this->tpl->set('{pages}', $rek_page);
      $this->tpl->compile('navigation');
      return $this->tpl->result['navigation'];
   }
   /**
    * BulletEnergyView::setBlockTopic()
    * Метод компиляции основного блока вокруг списка тем.
    * @param mixed $data - Входной массив данных на вывод.
    * @param mixed $data[topicList]  = Список тем для вывода либо информационное сообщение.
    * @param mixed $data[titlAction] = Заголовок (Заголовок категории либо заголовок раздела Новых тем)
    * @param mixed $data[treeDescr]  = Описание узла.
    * @param mixed $data[paginator]  = Пагинатор если есть.
    * @param mixed $data[optionList] = Дополнительные кнопки.
    * @return
    */
   public function setBlockTopic(array $data = array())
   {
      $this->tpl->load_template('block_topic.tpl');
      $this->tpl->set('{listTopic}', $data['topicList']);
      if($data['paginator']) {
         $this->tpl->set('{navigation}', $data['paginator']);
         $this->tpl->set('[navigation]', '');
         $this->tpl->set('[/navigation]', '');
      } else {
         $this->tpl->set('{navigation}', '');
         $this->tpl->set_block("'\\[navigation\\](.*?)\\[/navigation\\]'si", "");
      }
      $this->tpl->set('{treeDescription}', $data['treeDescr']);
      $this->tpl->set('{treeName}', $data['titlAction']);
      if(parent::$action == 'categories') {
         $this->tpl->set('[linckTreeName]', parent::$handler->linck->cat_linck($this->id, parent::$handler->totranslit(parent::$treePermanent[$this->id]['tree_title']), true, true) /*:TODO:*/ );
         $this->tpl->set('[/linckTreeName]', '</a>');
         if(in_array($this->id, explode(',', parent::$handler->_getGroupIdParseTree())) and parent::$modules_config['enable_rss'] and parent::$treePermanent[$this->id]['tree_topic'] > 0) {
            $this->tpl->set('{treeRss}', '<a class="optionTree" title="' . parent::$modules_lang['tree_10'] . '" href="' . parent::$handler->linck->rssTree($this->id) . '">' . parent::$modules_lang['tree_10'] . '</a>');
         } else {
            $this->tpl->set('{treeRss}', '');
         }
         if(parent::$logged_is) {
            $this->tpl->set('{treeOption}', '<a onclick="ReadTree(\'' . $this->id . '\'); return false;" href="#" class="optionTree">' . parent::$modules_lang['tree_7'] . '</a>');
         } else {
            $this->tpl->set('{treeOption}', '');
         }
         if(parent::$tree[$this->id]['tree_info_titl'] and parent::$tree[$this->id]['tree_info_text']) {
            $this->tpl->set('{infoTitl}', parent::$tree[$this->id]['tree_info_titl']);
            $this->tpl->set('{infoText}', parent::$tree[$this->id]['tree_info_text']);
            $this->tpl->set('[/infoBox]', '');
            $this->tpl->set('[infoBox]', '');
         } else {
            $this->tpl->set_block("'\\[infoBox\\](.*?)\\[/infoBox\\]'si", "");
         }
         if(parent::$handler->ckeckModulesConfig('be_sort')) {
         } else {
         }
      } else {
         $this->tpl->set('{treeRss}', '');
         $this->tpl->set_block("'\\[infoBox\\](.*?)\\[/infoBox\\]'si", "");
         $this->tpl->set('[linckTreeName]', '');
         $this->tpl->set('[/linckTreeName]', '');
         $this->tpl->set('{treeOption}', '');
      }
      $this->tpl->set('{optionList}', $data['optionList']);
      $this->tpl->compile('block_topic');
      return $this->tpl->result['block_topic'];
   }
   public function messge_topic($data = array())
   {
      //var_dump($data['like']);
      $edit = '';
      $option = array();
      if($data['isOnline'] and parent::$modules_config['online']) {
         $this->tpl->set('{isOnline}', parent::$modules_lang['msg_32']);
         $this->tpl->set('{isOnlineCss}', 'online');
      } elseif(!$data['isOnline'] and parent::$modules_config['online']) {
         $this->tpl->set('{isOnline}', parent::$modules_lang['msg_33']);
         $this->tpl->set('{isOnlineCss}', 'offline');
      } else {
         $this->tpl->set('{isOnline}', '');
         $this->tpl->set('{isOnlineCss}', '');
      }
      if($data['warning']) {
         $this->tpl->set('[isAccessWarning]', '');
         $this->tpl->set('[/isAccessWarning]', '');
         $this->tpl->set('{countWarning}', $data['countWarning']);
      } else {
         $this->tpl->set_block("'\\[isAccessWarning\\](.*?)\\[/isAccessWarning\\]'si", "");
      }
      $this->tpl->load_template('short_message.tpl');
      $this->tpl->set('{messageAutorIp}', $data['message_autor_ip']);
      $this->tpl->set('[popupUserCard]', parent::$handler->linck->card_user(array($data['message_autor'], $data['autors_id'])));
      $this->tpl->set('[/popupUserCard]', '</a>');
      $this->tpl->set('{autorName}', $data['message_autor']);
      $this->tpl->set('[/profile]', '</a>');
      $this->tpl->set('[profile]', parent::$handler->linck->linckUserSiteProfile($data['message_autor']));
      $this->tpl->set('[/profile]', '</a>');
      $this->tpl->set('[userTrophies]', $data['countTrophiesLinck']);
      $this->tpl->set('[/userTrophies]', $data['countTrophiesLinckOut']);
      $this->tpl->set('{lock}', $data['lock']);
      $this->tpl->set('{countTrophies}', $data['countTrophies']);
      $this->tpl->set('{messageId}', $data['mesage_id']);
      $this->tpl->set('{titleUser}', $data['titleUser']);
      if($data['titleUser']) {
         $this->tpl->set('[titleUser]', '');
         $this->tpl->set('[/titleUser]', '');
      } else {
         $this->tpl->set_block("'\\[titleUser\\](.*?)\\[/titleUser\\]'si", "");
      }
      $this->tpl->set('{messageLinck}', '<a class="getMessageLinck" onclick="getMessageLinck(\'' . $data['mesage_id'] . '\'); return false;" title="' . parent::$modules_lang['msg_13'] . '" href="' . parent::$handler->linck->postLinck($this->id, $data['mesage_id'], $data['titleTopic']) . '">#' . $data['id_msg_topic'] . '</a>');
      $this->tpl->set('{userGroup}', $data['user_group']);
      $this->tpl->set('{newsNum}', $data['news_num']);
      $this->tpl->set('{commNum}', $data['comm_num']);
      $this->tpl->set('{likeCountUser}', $data['likeCountUser']);
      if($data['likeCountUser']) {
         $this->tpl->set('[likeCountUser]', '');
         $this->tpl->set('[/likeCountUser]', '');
      } else {
         $this->tpl->set_block("'\\[likeCountUser\\](.*?)\\[/likeCountUser\\]'si", "");
      }
      if($data['countTrophies']) {
         $this->tpl->set('[isUserTrophies]', '');
         $this->tpl->set('[/isUserTrophies]', '');
      } else {
         $this->tpl->set_block("'\\[isUserTrophies\\](.*?)\\[/isUserTrophies\\]'si", "");
      }
      $this->tpl->set('{cssName}', $data['css_name']);
      $this->tpl->set('{like}', $data['like']);
      $this->tpl->set('{cssGroup}', $data['css_group']);
      $this->tpl->set('{regDate}', $data['reg_date']);
      $this->tpl->set('{foto}', $data['foto']);
      $this->tpl->set('{signature}', $data['signature']);
      if(parent::$modules_config['reputations']) {
         if($data['repa_off'] == 0) {
            $option['repa'] = explode('|', $data['repa_mod']);
            if(parent::$modules_config['reputations_type'] == 1) {
               $option['view'] = "(<font color=green><b>" . $option['repa'][0] . "</b></font><b>|</b><font color=red><b>" . $option['repa'][1] . "</b></font>)";
            } elseif(parent::$modules_config['reputations_type'] == 2) {
               $option['view'] = "(<font color=green><b>" . $option['repa'][0] . "</b></font><b>|<b>" . $data['repa'] . "</b>|</b><font color=red><b>" . $option['repa'][1] . "</b></font>)";
            } else {
               $option['view'] = $data['repa'];
            }
            $this->tpl->set('{reputation}', parent::$handler->linck->reputationPermaLinck($data['message_autor'], 'plus', '', $data['autors_id'], $data['mesage_id']) . parent::$handler->linck->reputationPermaLinck($data['message_autor'], 'user', $option['view']) . parent::$handler->linck->reputationPermaLinck($data['message_autor'], 'minus', '', $data['autors_id'], $data['mesage_id']));
         } else {
            $this->tpl->set('{reputation}', 'Выкл.');
         }
      }
      if(trim($data['signature'])) {
         $this->tpl->set('[signatureBox]', '');
         $this->tpl->set('[/signatureBox]', '');
      } else {
         $this->tpl->set_block("'\\[signatureBox\\](.*?)\\[/signatureBox\\]'si", "");
      }
      $this->tpl->set('{icq}', $data['icq']);
      $this->tpl->set('{forumPostNum}', $data['forum_post_count']);
      $this->tpl->set('{forumTopicNum}', $data['forum_topic_count']);
      //
      if($data['deleteMessage']) {
         $this->tpl->set('[deleteMsg]', "<a href=\"javascript:DeleteMsg('{$data['mesage_id']}','" . parent::$hash_login . "')\" class=\"edit top\">");
         $this->tpl->set('[/deleteMsg]', '</a>');
      } else {
         $this->tpl->set_block("'\\[deleteMsg\\](.*?)\\[/deleteMsg\\]'si", "");
      }
      if($data['editCommentAccess']) {
         $this->tpl->set('[msgEdit]', "<a href=\"javascript:;\" onclick=\"MsgEdit('{$data['mesage_id']}','" . parent::$hash_login . "'); return false;\" class=\"edit top\">");
         $this->tpl->set('[/msgEdit]', '</a>');
      } else {
         $this->tpl->set_block("'\\[msgEdit\\](.*?)\\[/msgEdit\\]'si", "");
      }
      if($data['fast']) {
         $this->tpl->set('[fast]', "<a onmouseover=\"copy_fast_insert('" . str_replace(array(" ", "&#039;"), array("&nbsp;", "&amp;#039;"), $data['message_autor']) . "');\" href=\"javascript:;\" onclick=\"fast_insert('" . str_replace(array(" ", "&#039;"), array("&nbsp;", "&amp;#039;"), $data['message_autor']) . "'); return false;\">");
         $this->tpl->set('[/fast]', "</a>");
      } else {
         $this->tpl->set_block("'\\[fast\\](.*?)\\[/fast\\]'si", "");
      }
      if($data['complaint']) {
         $this->tpl->set('[complaint]', "<a class=\"ComplaintMessageLinck\" href=\"javascript:PostComplaint('{$data['mesage_id']}')\">");
         $this->tpl->set('[/complaint]', '</a>');
      } else {
         $this->tpl->set_block("'\\[complaint\\](.*?)\\[/complaint\\]'si", "");
      }
      $this->tpl->set('{messageDate}', $data['message_date']);
      if($data['msg_edit_date']) {
         $edit = '<div class="EditMsgView">' . parent::$modules_lang['msg_12'] . $data['edit_autor'] . ' ' . date('d.m.Y в H:i', $data['msg_edit_date']) . '</div>';
      }
      if(parent::$groups_config[parent::$id_member['user_group']]['be_access_hide']) {
         $data['message_text'] = str_ireplace("[hide]", "", str_ireplace("[/hide]", "", $data['message_text']));
      } else {
         $data['message_text'] = preg_replace("#\[hide\](.+?)\[/hide\]#ims", "<div class=\"HideNo\">" . parent::$modules_lang['msg_11'] . "</div>", $data['message_text']);
      }
      $this->tpl->set('{editorInfo}', $edit);
      $this->tpl->set('{messageText}', '<div id="MsgTextBox-' . $data['mesage_id'] . '">' . $data['message_text'] . '</div>'); //
      $this->tpl->compile('short_message');
   }
   public function setTplMessageSearchUser($data = array())
   {
      $edit = '';
      $this->tpl->load_template('other_topic_post.tpl');
      $this->tpl->set('[profile]', parent::$handler->linck->linckUserSiteProfile($data['message_autor']));
      $this->tpl->set('[/profile]', '</a>');
      $this->tpl->set('{foto}', $data['foto']);
      $this->tpl->set('[popupUserCard]', parent::$handler->linck->card_user(array($data['message_autor'], $data['autors_id'])));
      $this->tpl->set('[/popupUserCard]', '</a>');
      $this->tpl->set('{titleTopic}', $data['title']);
      $this->tpl->set('[linckTopic]', parent::$handler->linck->topic_linck($data['id'], parent::$handler->totranslit($data['title'], true, true)));
      $this->tpl->set('[/linckTopic]', '</a>');
      $this->tpl->set('[linckMessage]', '<a href="' . parent::$handler->linck->postLinck($data['id'], $data['post_id'], parent::$handler->totranslit($data['title'], true, true)) . '">');
      $this->tpl->set('[/linckMessage]', '</a>');
      $this->tpl->set('{nameTree}', $data['titlTree']);
      $this->tpl->set('[linckTree]', parent::$handler->linck->cat_linck($data['idTree'], parent::$handler->totranslit(parent::$treePermanent[$data['idTree']]['tree_title'], true, true)));
      $this->tpl->set('[/linckTree]', '</a>');
      $this->tpl->set('{messageAuthor}', $data['message_autor']);
      $this->tpl->set_block("'\\[topic\\](.*?)\\[/topic\\]'si", "");
      $this->tpl->set('[msg]', '');
      $this->tpl->set('[/msg]', '');
      $this->tpl->set('{messageDate}', $data['message_date']);
      if($data['msg_edit_date']) {
         $edit = '<div class="EditMsgView">' . parent::$modules_lang['msg_12'] . $data['edit_autor'] . ' ' . date('d.m.Y в H:i', $data['msg_edit_date']) . '</div>';
      }
      if(parent::$groups_config[parent::$id_member['user_group']]['be_access_hide']) {
         $data['message_text'] = str_ireplace("[hide]", "", str_ireplace("[/hide]", "", $data['message_text']));
      } else {
         $data['message_text'] = preg_replace("#\[hide\](.+?)\[/hide\]#ims", "<div class=\"HideNo\">" . parent::$modules_lang['msg_11'] . "</div>", $data['message_text']);
      }
      $this->tpl->set('{messageText}', $data['message_text']);
      $this->tpl->set('{editorInfo}', $edit);
      $this->tpl->compile('short_message');
   }
   public function setTplMessageModeration($data = array())
   {
   }
   public function topic_search_user($data = array())
   {
      $edit = '';
      $this->tpl->load_template('other_topic_post.tpl');
      $this->tpl->set('{foto}', $data['foto']);
      $this->tpl->set('[popupUserCard]', parent::$handler->linck->card_user(array($data['message_autor'], $data['autors_id'])));
      $this->tpl->set('[/popupUserCard]', '</a>');
      $this->tpl->set('{titleTopic}', $data['title']);
      $this->tpl->set('[linckTopic]', parent::$handler->linck->topic_linck($data['id'], parent::$handler->totranslit($data['title'], true, true)));
      $this->tpl->set('[/linckTopic]', '</a>');
      $this->tpl->set('{nameTree}', $data['titlTree']);
      $this->tpl->set('{replyCount}', $data['reply_count']);
      $this->tpl->set('[linckTree]', parent::$handler->linck->cat_linck($data['idTree'], parent::$handler->totranslit(parent::$treePermanent[$data['idTree']]['tree_title'], true, true)));
      $this->tpl->set('[/linckTree]', '</a>');
      $this->tpl->set_block("'\\[msg\\](.*?)\\[/msg\\]'si", "");
      $this->tpl->set('[topic]', '');
      $this->tpl->set('[/topic]', '');
      $this->tpl->set('{messageAuthor}', $data['message_autor']);
      $this->tpl->set('[profile]', parent::$handler->linck->linckUserSiteProfile($data['message_autor']));
      $this->tpl->set('[/profile]', '</a>');
      $this->tpl->set('{messageDate}', $data['message_date']);
      if($data['msg_edit_date']) {
         $edit = '<div class="EditMsgView">' . parent::$modules_lang['msg_12'] . $data['edit_autor'] . ' ' . date('d.m.Y в H:i', $data['msg_edit_date']) . '</div>';
      }
      if(parent::$groups_config[parent::$id_member['user_group']]['be_access_hide']) {
         $data['message_text'] = str_ireplace("[hide]", "", str_ireplace("[/hide]", "", $data['message_text']));
      } else {
         $data['message_text'] = preg_replace("#\[hide\](.+?)\[/hide\]#ims", "<div class=\"HideNo\">" . parent::$modules_lang['msg_11'] . "</div>", $data['message_text']);
      }
      $this->tpl->set('{messageText}', $data['message_text']); //
      $this->tpl->set('{editorInfo}', $edit);
      $this->tpl->compile('short_message');
   }
   public function setTplViewFullTopic($data = array())
   {
      //var_dump($data['topicName']);
      $this->tpl->load_template('block_full_topic.tpl');
      $this->tpl->set('{message_list}', $data['message'] . '<li id="addNewMsg"></li>');
      $this->tpl->set('{navigation}', $data['paginator']);
      $this->tpl->set('{topicName}', $data['topicName']);
      $this->tpl->set('{share}', $data['share']);
      $this->tpl->set('{topicOption}', $data['optionSel']);
      $this->tpl->set('{topicVote}', $data['vote']);
      $this->tpl->set('{topicDescription}', $data['topicDescrSite']);
      $this->tpl->compile('block_full_topic');
      return $this->tpl->result['block_full_topic'] . $data['replic'];
   }
   public function setTplSearchPage(array $data = array())
   {
      //unset($this->tpl->result['search']);
      $this->tpl->load_template('search.tpl');
      $this->tpl->set('{tree}', $data['tree']);
      $this->tpl->set('{keyValue}', $data['keyValue']);
      $this->tpl->set('{keyOnliTitle}', $data['keyOnliTitle'] == 1 ? 'checked="checked"' : '');
      $this->tpl->set('{keyUser}', $data['keyUser']);
      $this->tpl->set('{keyDate}', $data['keyDate']);
      $this->tpl->set('{keyDateOut}', $data['keyDateOut']);
      $this->tpl->set('{keyDateSort}', $data['sort'] == 1 ? 'checked="checked"' : '');
      $this->tpl->set('{keyReplySort}', $data['sort'] == 0 ? 'checked="checked"' : '');
      $this->tpl->set('{sortDesc}', $data['order'] == 'DESC' ? 'selected="selected"' : '');
      $this->tpl->set('{sortAsc}', $data['order'] == 'ASC' ? 'selected="selected"' : '');
      $this->tpl->compile('search');
      return '<form method="post" action=""  id="search_forum" name="search_forum">' . $this->tpl->result['search'] . '<input type="hidden" name="action" value="search_proccess" /><input type="hidden" name="result" value="' . $data['page'] . '" /><input type="hidden" name="page" value="' . $data['page'] . '" /></form>';
   }
   public function setTopicList($data = array())
   {
      $this->tpl->load_template('short_topic.tpl');
      $this->tpl->set('{id}', $data['id']);
      $this->tpl->set('{title}', $data['title']);
      $this->tpl->set('{replyCount}', $data['reply_count']);
      $this->tpl->set('{viewCount}', $data['view_count']);
      $this->tpl->set('{description}', $data['site_description']);
      $this->tpl->set('{topicPostDate}', $data['post_date']);
      if(empty($data['isUnreadLinckPost']) and parent::$logged_is) {
         $this->tpl->set('{unreadLinck}', '<a title="' . parent::$modules_lang['topic_87'] . '" href="' . parent::$handler->linck->topicIsUnread($data['id'], parent::$handler->totranslit($data['title'], true, true)) . '" class="unreadPostLinck"></a>');
      } else {
         $this->tpl->set('{unreadLinck}', '');
      }
      $this->tpl->set('{autor}', parent::$handler->linck->user_linck($data['autor']));
      $this->tpl->set('[linck]', parent::$handler->linck->topic_linck($data['id'], parent::$handler->totranslit($data['title'], true, true)));
      $this->tpl->set('[/linck]', '</a>');
      $this->tpl->set('{edit}', $data['editButton']);
      $this->tpl->set('{pageList}', $data['pageList']);
      $this->tpl->set('{uniqueStatusTopic}', $data['uniqueStatusTopic']);
      $this->tpl->set('{icon}', $data['icon']);
      if($data['last']) {
         $this->tpl->set('{lastAutorAvatarLinck}', parent::$handler->isAvatarUser($data['last'][4]));
         $this->tpl->set('{lastAutorName}', $data['last'][0]);
         $this->tpl->set('{lastTopicName}', htmlspecialchars($data['last'][2]));
         $this->tpl->set('[lastMessageLinck]', '<a href="' . $data['last'][3] . '">');
         $this->tpl->set('[/lastMessageLinck]', '</a>');
         $this->tpl->set('[popupUserCard]', parent::$handler->linck->card_user(array($data['last'][0], $data['last'][5])));
         $this->tpl->set('[/popupUserCard]', '</a>');
         if(date('Ymd', $data['last'][1]) == date('Ymd', parent::$handler->time)) {
            $this->tpl->set('{lastMessageDate}', parent::$modules_lang['time_heute'] . parent::$handler->langdate(", H:i", $data['last'][1]));
         } elseif(date('Ymd', $data['last'][1]) == date('Ymd', (parent::$handler->time - 86400))) {
            $this->tpl->set('{lastMessageDate}', parent::$modules_lang['time_gestern'] . parent::$handler->langdate(", H:i", $data['last'][1]));
         } else {
            $this->tpl->set('{lastMessageDate}', parent::$handler->langdate('j F Y', $data['last'][1]));
         }
         $this->tpl->set('[LastMessage]', '');
         $this->tpl->set('[/LastMessage]', '');
         $this->tpl->set('[profile]', parent::$handler->linck->linckUserSiteProfile($data['last'][0]));
         $this->tpl->set('[/profile]', '</a>');
      } else {
         $this->tpl->set_block("'\\[LastMessage\\](.*?)\\[/LastMessage\\]'si", ""); //:TODO: is topic wtf last post?
      }
      $this->tpl->set('{status}', $data['status_read']);
      $this->tpl->set('{statusTitl}', $data['statusTitl']);
      return $this->tpl->compile('short_topic');
   }
   public function setTplMainBlock($data = '', $meta = array(), $option = array())
   {
      parent::$handler->strLeght();
      parent::$meta['title'] = stripslashes($meta[0]);
      parent::$meta['description'] = stripslashes($meta[1]);
      parent::$meta['keywords'] = stripslashes($meta[2]);
      $speedbar = $this->setSpeedbar(array('noVisible' => $option['spedbarVisible'], 'titlAction' => $option['spedbar']['titlAction'], 'titlTree' => $option['spedbar']['titlTree'], 'idTree' => $option['spedbar']['idTree'], 'topicId' => $option['spedbar']['topicId']));
      $navigate = $this->set_navigate();
      $this->tpl->load_template('main_forum.tpl');
      $this->tpl->set('{content_forum}', $data);
      $this->tpl->set('{speedbar}', $speedbar);
      $this->tpl->set('{navigate_forum}', $navigate);
      $buttom_block = parent::$handler->set_buttom(array('id' => $option['spedbar']['idTree']));
      if($buttom_block) {
         $this->tpl->set('{buttom}', $buttom_block);
         $this->tpl->set('[buttom]', '');
         $this->tpl->set('[/buttom]', '');
      } else {
         $this->tpl->set_block("'\\[buttom\\](.*?)\\[/buttom\\]'si", "");
      }
      $this->tpl->set('{widgetOnline}', $option['widget']['online']);
      $this->tpl->set('{widgetMessage}', $option['widget']['message']);
      $this->tpl->compile('main_forum');
      return '<div id="bullet_energy">' . $this->tpl->result['main_forum'] . $this->tplIsCompile['data'] . '</div>';
   }
   /**
    * BulletEnergyView::set_navigate()
    * Метод установки блока навигации на форуме (Главная, форум, помощь)
    * @return
    */
   public function set_navigate()
   {
      if(trim(parent::$modules_config['url_site']) != "") {
         $main .= '<li><a href="' . parent::$modules_config['url_site'] . '">' . parent::$modules_lang['main'] . '</a></li>';
      }
      if(!parent::$logged_is and intval(parent::$modules_config['reg_linck_5']) == 1) {
         $main .= '<li><a href="' . parent::$config_dle['http_home_url'] . 'index.php?do=register">' . parent::$modules_lang['register'] . '</a></li>';
      }
      $main .= '<li><a href="' . parent::$handler->linck->linckMainPageForum() . '">' . parent::$modules_lang['forum'] . '</a></li>';
      if(parent::$logged_is) {
         $main .= '<li><a href="' . parent::$handler->linck->sub_navigate_linck('new_post') . '">' . parent::$modules_lang['what_new'] . '</a></li>';
         $main .= '<li><a href="' . parent::$handler->linck->watchedLinck() . '">' . parent::$modules_lang['topicVis'] . '</a></li>';
      }
      if(parent::$handler->ckeckModulesConfig('be_access_search')) {
         $main .= '<li><a href="' . parent::$handler->linck->searchLinck() . '">' . parent::$modules_lang['search_post'] . '</a></li>';
      }
      if(parent::$moderator[parent::$id_member['user_id']] and !parent::$modules_config['moder_disable']) {
         $main .= '<li><a href="' . parent::$handler->linck->linckModeration() . '">' . parent::$modules_lang['moderation'] . '</a></li>';
      }
      return '<ul class="main_menu">' . $main . '</ul>';
   }
   private function getPosotionUserTree($option = 0, $marker = false)
   {
      $marker = $marker ? array('a' => 'class="no_linck"', 'li' => 'class="last"') : array('linck' => 'href="' . parent::$handler->linck->treeLinck($option, parent::$handler->totranslit(parent::$treePermanent[$option]['tree_title'], true, true)) . '"');
      $treeId = parent::$treePermanent[$option]['tree_parent_id'];
      $treeInfo = parent::$treePermanent;
      $list = "<li {$marker['li']}><a {$marker['a']} {$marker['linck']}>{$treeInfo[$option]['tree_title']}</a><span class=\"arrow\"><span></span></span></li>";
      while ($treeId) {
         $list = '<li>' . parent::$handler->linck->cat_linck($treeId, parent::$handler->totranslit(parent::$treePermanent[$treeId]['tree_title'], true, true)) . "{$treeInfo[$treeId]['tree_title']}</a><span class=\"arrow\"><span></span></span></li>" . $list;
         $treeId = $treeInfo[$treeId]['tree_parent_id'];
         if($treeInfo[$treeId]['tree_parent_id'] == 0 and $treeInfo[$treeId]['tree_type'] != 0) {
            break;
         }
      }
      return $list;
   }
   //$quick_nav = '<li class="FastNav"><a class="ButtonFastNav" title="' . parent::$modules_lang['qick_nav'] . '" href="javascript:;GetQuikNav()">&nbsp;</a></li>';
   public function setSpeedbar($data = array())
   {
      //11.07.2011
      $speedbar = '<li class="home"><a title="' . parent::$modules_lang['go_site'] . '" href="' . parent::$modules_config['url_site'] . '">' . parent::$modules_lang['main'] . ' </a><span class="arrow"><span></span></span></li>';
      $speedbar .= parent::$action == 'main' ? '<li class="last"><a class="no_linck" title="' . parent::$modules_lang['go_forum'] . '">' . parent::$modules_lang['forum'] . ' ' . parent::$modules_config['speedbar_titl'] . ' </a><span class="arrow"><span></span></span></li>' : '<li><a title="' . parent::$modules_lang['go_forum'] . '" href="' . parent::$handler->linck->linckMainPageForum() . '">' . parent::$modules_lang['forum'] . ' ' . parent::$modules_config['speedbar_titl'] . ' </a><span class="arrow"><span></span></span></li>';
      switch (parent::$action) {
         case 'categories':
            $speedbar .= $this->getPosotionUserTree($this->id, true);
            break;
         case 'showtopic':
            $speedbar .= $this->getPosotionUserTree($data['idTree'], false) . '<li class="last"><a class="no_linck">' . $data['titlAction'] . '</a><span class="arrow"><span></span></span></li>';
            break;
         case 'new_post':
            $speedbar .= '<li class="last"><a class="no_linck">' . parent::$modules_lang['what_new'] . '</a><span class="arrow"><span></span></span></li>';
            break;
         case 'newtopic':
            $speedbar .= $this->getPosotionUserTree($this->id) . '<li class="last"><a class="no_linck">' . parent::$modules_lang['topic_new_0'] . '</a><span class="arrow"><span></span></span></li>';
            break;
         case 'message_user':
            $speedbar .= '<li class="last"><a class="no_linck">' . $data['titlAction'] . '</a><span class="arrow"><span></span></span></li>';
            break;
         case 'topic_user':
            $speedbar .= '<li class="last"><a class="no_linck">' . $data['titlAction'] . '</a><span class="arrow"><span></span></span></li>';
            break;
         case 'add_message':
            $speedbar .= $this->getPosotionUserTree($data['idTree']) . '<li>' . parent::$handler->linck->topic_linck($data['topicId'], parent::$handler->totranslit($data['titlAction'], true, true)) . $data['titlAction'] . '</a><span class="arrow"><span></span></span></li><li class="last"><a class="no_linck">' . parent::$modules_lang['topic_40'] . '</a><span class="arrow"><span></span></span></li>';
            break;
         case 'findpost':
            $speedbar .= '<li class="last"><a class="no_linck">' . $data['titlAction'] . '</a><span class="arrow"><span></span></span></li>';
            break;
         case 'moderation':
            $speedbar .= '<li class="last"><a class="no_linck">' . $data['titlAction'] . '</a><span class="arrow"><span></span></span></li>';
         case 'watched':
            $speedbar .= '<li class="last"><a class="no_linck">' . parent::$modules_lang['topicVis'] . '</a><span class="arrow"><span></span></span></li>';
            break;
         case 'watched_all':
            $speedbar .= '<li class="last"><a class="no_linck">' . parent::$modules_lang['topicVis'] . '</a><span class="arrow"><span></span></span></li>';
            break;
      }
      $this->tpl->load_template('speedbar.tpl');
      $this->tpl->set('{speedbar}', '<ul>' . $speedbar . '</ul>');
      $this->tpl->compile('speedbar');
      return $this->tpl->result['speedbar'];
   }
}

?>