/** * Возвращает один или несколько (все) комментариев в текущем этапе. * * @param integer|string $msg_id один или несколько ид. комментов, разделенных запятыми. Если NULL, то будут возвращены все сообщения в виде дерева. * @param boolean $get_attach включить вложения в данные? * @return array массив сообщений. NULL -- ошибка. */ function getMsgs($msg_id = NULL, $get_attach = true) { $sended = $this->sbr->sended ? $this->sbr->sended : $this->sbr->posted; // Если нет даты то хоть какую то дату // Нужно брать сообщения, начиная с даты отправки ТЗ текущему исполнителю, чтобы не попала переписка со старым исполнителем. $where = "sm.post_date > '{$sended}' AND sm.stage_id = {$this->id}" . ($msg_id == NULL ? '' : " AND sm.id IN ({$msg_id})"); $sql = "\n SELECT sm.*, u.login, u.uname, u.usurname, u.photo, u.role, u.is_pro, u.is_pro_test, u.is_team, ssa.date_to_answer\n FROM sbr_stages_msgs sm\n INNER JOIN\n users u\n ON u.uid = sm.user_id\n LEFT JOIN\n sbr_stages_arbitrage ssa\n ON ssa.stage_id = sm.stage_id\n WHERE {$where}\n ORDER BY sm.parent_id, sm.post_date\n "; if (!($res = pg_query(self::connect(false), $sql)) || !pg_num_rows($res)) { return NULL; } $msgs_id = array(); while ($row = pg_fetch_assoc($res)) { $msgs_id[] = $row['id']; $msgs[$row['id']] = $row; } if ($get_attach) { $msgs_id = implode(',', $msgs_id); if ($atts = $this->getMsgAttach($msgs_id)) { foreach ($atts as $id => $att) { $msgs[$att['msg_id']]['attach'][$id] = $att; } } } if (!$msg_id) { return array2tree($msgs, 'id', 'parent_id', true); } return current($msgs); }
} } } function _html_buildlist(&$data) { $ret = array(); foreach ($data as $item) { $ret[] = "<li" . ($item['type'] == 'd' ? " class=\"dir\" " : '') . ">"; $ret[] = preg_replace("#^<span[^>]+>(.+)</span>\$#i", "\$1", html_wikilink(":" . $item['target'], null)); // append child nodes, if exists if ($item['type'] == 'd') { //isset($item['child_nodes'])) { if (isset($item['child_nodes'])) { $ret[] = "<ul>"; // static method used to be able to make menu w/o make class object $ret[] = _html_buildlist($item['child_nodes']); $ret[] = "</ul>"; } } $ret[] = "</li>"; } return join("\n", $ret); } $data = array(); search($data, $conf['datadir'], "indexmenu_search_index", $opts, "/" . utf8_encodeFN(str_replace(':', '/', $ns)), 2); foreach ($data as $k => $v) { $data[$k]['parent_id'] = (string) getNS($v['id']); } $data = array2tree($data, ''); $data = "<ul class=\"generated-index\">" . _html_buildlist($data) . "</ul>"; echo $data;
/** * Выводит все комментарии на страницу * * @return string HTML код */ public function render() { $user_is_subscribe_on_topic = commune::isCommuneTopicSubscribed($this->_resource_id, get_uid(false)); $uid = get_uid(false); $comments = $this->getData(); $this->msg_num = count($comments); $comments = array('children' => array2tree($comments, 'id', 'parent_id', true)); $comments_html = $this->msg_nodes($comments); if (!$GLOBALS['top']['deleted_id']) { $form = $this->renderForm(); } ob_start(); include $this->tpl_path . $this->templates['main']; return ob_get_clean(); }
/** * 获取帖子回复的评论 * @param int $feed_id 帖子id */ public function getSubComment($feed_id) { $map['row_id'] = array('eq', $feed_id); $map['is_del'] = array('eq', 0); $map['to_comment_id'] = array('neq', 0); $comments = M('Comment')->where($map)->order('comment_id ASC')->findAll(); foreach ($comments as $v) { $comment_info['type'] = '回复了评论'; $comment_info['to_uid'] = $v['to_uid']; $comment_info['to_uid_info'] = $this->get_user_info($v['to_uid']); $comment_info['user_info'] = $this->get_user_info($v['uid']); $comment_info['to_comment_id'] = $v['to_comment_id']; $comment_info['comment_id'] = $v['comment_id']; $comment_info['content'] = $v['content']; $comment_info['ctime'] = $v['ctime']; $comment_info['digg_count'] = $v['digg_count']; $diggarr = model('CommentDigg')->checkIsDigg($v['comment_id'], $GLOBALS['ts']['mid']); $comment_info['is_digg'] = t($diggarr[$v['comment_id']] ? 1 : 0); $commenList[] = $comment_info; } $commenList = array2tree($commenList, 'comment_id', 'to_comment_id', 'child'); return $commenList; }
/** * Выводит все комментарии на страницу * * @return string HTML код */ public function render() { $uid = get_uid(false); $comments = $this->getData(); $this->msg_num = count($comments); $comments = array('children' => array2tree($comments, 'id', 'parent_id', true)); $comments_html = $this->msg_nodes($comments); $form = $this->renderForm(); ob_start(); include $this->tpl_path . $this->templates['main']; return ob_get_clean(); }