Войти
Введите цифры и буквы
Владимир
/** * Проверяем есть ли заголовок топика */ if (!func_check(getRequest('topic_title',null,'post'),'text',2,200)) {
<?php /*------------------------------------------------------- * * LiveStreet Engine Social Networking * Copyright © 2008 Mzhelskiy Maxim * *-------------------------------------------------------- * * Official site: www.livestreet.ru * Contact e-mail: rus.engine@gmail.com * * GNU General Public License, version 2: * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * --------------------------------------------------------- */ /** * Обрабатывает голосование за топик-вопрос */ set_include_path(get_include_path().PATH_SEPARATOR.dirname(dirname(dirname(__FILE__)))); $sDirRoot=dirname(dirname(dirname(__FILE__))); require_once($sDirRoot."/config/config.ajax.php"); $idAnswer=getRequest('idAnswer',null,'post'); $idTopic=getRequest('idTopic',null,'post'); $bStateError=true; $sTextResult=''; $sMsgTitle=''; $sMsg=''; if ($oEngine->User_IsAuthorization()) { if ($oTopic=$oEngine->Topic_GetTopicById($idTopic)) { if ($oTopic->getType()=='question') { //голосовал уже или нет $oUserCurrent=$oEngine->User_GetUserCurrent(); if (!($oTopicQuestionVote=$oEngine->Topic_GetTopicQuestionVote($oTopic->getId(),$oUserCurrent->getId()))) { $aAnswer=$oTopic->getQuestionAnswers(); if (isset($aAnswer[$idAnswer]) or $idAnswer==-1) { if ($idAnswer==-1) { $oTopic->setQuestionCountVoteAbstain($oTopic->getQuestionCountVoteAbstain()+1); } else { $oTopic->increaseQuestionAnswerVote($idAnswer); } $oTopic->setQuestionCountVote($oTopic->getQuestionCountVote()+1); $oTopicQuestionVote=Engine::GetEntity('Topic_TopicQuestionVote'); $oTopicQuestionVote->setTopicId($oTopic->getId()); $oTopicQuestionVote->setVoterId($oUserCurrent->getId()); $oTopicQuestionVote->setAnswer($idAnswer); if ($oEngine->Topic_AddTopicQuestionVote($oTopicQuestionVote) and $oEngine->Topic_updateTopic($oTopic)) { $bStateError=false; $sMsgTitle=$oEngine->Lang_Get('attention'); $sMsg=$oEngine->Lang_Get('topic_question_vote_ok'); $oEngine->Viewer_Assign('oTopic',$oTopic); $sTextResult=$oEngine->Viewer_Fetch("topic_question.tpl"); } else { $sMsgTitle=$oEngine->Lang_Get('error'); $sMsg=$oEngine->Lang_Get('system_error'); } } else { $sMsgTitle=$oEngine->Lang_Get('error'); $sMsg=$oEngine->Lang_Get('system_error'); } } else { $sMsgTitle=$oEngine->Lang_Get('error'); $sMsg=$oEngine->Lang_Get('topic_question_vote_already'); } } else { $sMsgTitle=$oEngine->Lang_Get('error'); $sMsg=$oEngine->Lang_Get('system_error'); } } else { $sMsgTitle=$oEngine->Lang_Get('error'); $sMsg=$oEngine->Lang_Get('system_error'); } } else { if ($oTopic=$oEngine->Topic_GetTopicById($idTopic)) { if ($oTopic->getType()=='question') { //голосовал уже или нет //$oUserCurrent=$oEngine->User_GetUserCurrent(); if (!isset($_SESSION['voted_'.$oTopic->getId()])) { $aAnswer=$oTopic->getQuestionAnswers(); if (isset($aAnswer[$idAnswer]) or $idAnswer==-1) { if ($idAnswer==-1) { $oTopic->setQuestionCountVoteAbstain($oTopic->getQuestionCountVoteAbstain()+1); } else { $oTopic->increaseQuestionAnswerVote($idAnswer); } $oTopic->setQuestionCountVote($oTopic->getQuestionCountVote()+1); /*$oTopicQuestionVote=Engine::GetEntity('Topic_TopicQuestionVote'); $oTopicQuestionVote->setTopicId($oTopic->getId()); $oTopicQuestionVote->setVoterId($oUserCurrent->getId()); $oTopicQuestionVote->setAnswer($idAnswer); */ if (/*$oEngine->Topic_AddTopicQuestionVote($oTopicQuestionVote) and */$oEngine->Topic_updateTopic($oTopic)) { $bStateError=false; $sMsgTitle=$oEngine->Lang_Get('attention'); $sMsg=$oEngine->Lang_Get('topic_question_vote_ok'); $oEngine->Viewer_Assign('oTopic',$oTopic); $sTextResult=$oEngine->Viewer_Fetch("topic_question.tpl"); $_SESSION['voted_'.$oTopic->getId()] = true; } else { $sMsgTitle=$oEngine->Lang_Get('error'); $sMsg=$oEngine->Lang_Get('system_error'); } } else { $sMsgTitle=$oEngine->Lang_Get('error'); $sMsg=$oEngine->Lang_Get('system_error'); } } else { $sMsgTitle=$oEngine->Lang_Get('error'); $sMsg=$oEngine->Lang_Get('topic_question_vote_already'); } } else { $sMsgTitle=$oEngine->Lang_Get('error'); $sMsg=$oEngine->Lang_Get('system_error'); } } else { $sMsgTitle=$oEngine->Lang_Get('error'); $sMsg=$oEngine->Lang_Get('system_error'); } } $GLOBALS['_RESULT'] = array( "bStateError" => $bStateError, "sText" => $sTextResult, "sMsgTitle" => $sMsgTitle, "sMsg" => $sMsg, ); ?>
<div id="topic_question_area_{$oTopic->getId()}">
<div id="topic_question_area_{$oTopic->getId()}"> {assign var="iTopicId" value=$oTopic->getId()} {assign var="voted" value="voted_`$iTopicId`"} {if ($oUserCurrent && !$oTopic->getUserQuestionIsVote()) || (!$oUserCurrent && (!$smarty.session.$voted))}
if ($_SERVER["HTTP_HOST"] == 'm.site.ru') { $config['view']['skin'] = 'm'; } else { $config['view']['skin'] = 'new'; }
{include file='window_load_img.tpl' sToLoad='form_comment_text'}
<a class="test" href="#" onclick="showImgUploadForm(); return false;" class="button"><img src="{cfg name='path.static.skin'}/images/panel/img.gif" width="20" height="20" title="изображение"></a>
public function RegisterHook() { $this->AddHook('topic_show','TopicShow'); }
public function TopicShow($aParams) { $oTopic=$aParams['oTopic']; $oTopic->setCountRead($oTopic->getCountRead()+1); $this->Topic_UpdateTopic($oTopic); }
и поправить в таблице prefix_topic длинну поля topic_title — при необходимости сменить тип, ибо varchar максимум 255.
только вот главный вопрос зачем сей наворот нужен?
2. в шаблонах вывода топика (topic.tpl/topic_list.tpl) рядом с заменить на
я делал так: в конфиге заменить в начале скин на
файл /templates/skin/new/comment_tree.tpl
в строку 2 вставляем
затем после строки 87 вставляем
сохраняем, наслаждаемся графическим контентом/мусором (нужное подчеркнуть) в комментах