exit(0); } if (!preg_match("/^[a-f0-9]{32}\$/", $section_id)) { $ret_info->detail = t('Bad section!'); echo $json->encode($ret_info); exit(0); } $section_info = DocSectionManager::getSectionInfo($domain_handle, $section_id); if ($section_info == false) { $ret_info->detail = t('No such section!'); echo $json->encode($ret_info); exit(0); } $ret_info->status = 'success'; $ret_info->nr_total_comments = $section_info['nr_comments']; $comments = DocSectionManager::getCachedComments($domain_handle, $section_id); if (count($comments) == 0) { $ret_info->detail = ''; echo $json->encode($ret_info); exit(0); } if ($nr_comments < 1) { $nr_comments = 1; } $nr = 0; $ret_info->detail = '<ul class="list-group" style="width:300px;">'; foreach ($comments as $comment) { if ($nr >= $nr_comments) { break; } $author_name_info = FSEInfo::getNameInfo($comment['author_id']);
if ($sections == false) { $db = Loader::db(); $sections = $db->getAll("SELECT id, author_id, curr_ver_code, page_id,\n\t\tnr_comments, nr_praise, nr_favorites,\n\t\tproject_id, domain_handle, volume_handle, part_handle, chapter_handle\n\tFROM fsen_document_sections_{$doc_lang} WHERE heat_level > 0\n\tORDER BY heat_level DESC, create_time DESC LIMIT 20"); Cache::set('LatestCommentedSections', $doc_lang, $sections, 180); } $ret_info->status = 'success'; $nr = 0; foreach ($sections as $pst) { if ($nr >= $nr_requested) { break; } $author_info = FSEInfo::getNameInfo($pst['author_id']); if ($author_info == false) { continue; } $comments = DocSectionManager::getCachedComments($domain_handle, $pst['id']); if (count($comments) == 0) { continue; } $plain_content = DocSectionManager::getPlainContent($pst['id'], $pst['curr_ver_code']); $link = ProjectInfo::assemblePath($pst['project_id'], $pst['domain_handle'], $pst['volume_handle'], $pst['part_handle'], $pst['chapter_handle']); $link .= '#section-' . $pst['id']; if (strlen($plain_content['title']) == 0) { $page = Page::getByID($pst['page_id']); $plain_content['title'] = $page->getCollectionName(); } $ret_info->detail .= ' <div class="panel panel-default"> <div class="panel-body"> <div class="media" style="margin-top:15px"> <a class="media-left" href="' . FSEInfo::getPersonalHomeLink($author_info) . '">
<div class="container-fluid"> <div class="row"> <div class="col-md-6"> <h1> <?php echo t('Hot Commented Posts'); ?> </h1> <ul class="list-group"> <?php foreach ($hot_commented_posts as $pst) { $author_info = FSEInfo::getNameInfo($pst['author_id']); if ($author_info == false) { continue; } $comments = DocSectionManager::getCachedComments(false, $pst['id']); if (count($comments) == 0) { continue; } $plain_content = DocSectionManager::getPlainContent($pst['id'], $pst['curr_ver_code']); $link = ProjectInfo::assemblePath($pst['project_id'], $pst['domain_handle'], $pst['volume_handle'], $pst['part_handle'], $pst['chapter_handle']); $link .= '#section-' . $pst['id']; if (strlen($plain_content['title']) == 0) { $page = Page::getByID($pst['page_id']); $plain_content['title'] = $page->getCollectionName(); } ?> <li class="list-group-item"> <div class="media"> <a class="media-left" href="<?php echo FSEInfo::getPersonalHomeLink($author_info);