本文整理汇总了PHP中calc_page_limit函数的典型用法代码示例。如果您正苦于以下问题:PHP calc_page_limit函数的具体用法?PHP calc_page_limit怎么用?PHP calc_page_limit使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了calc_page_limit函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index_action
public function index_action()
{
if ($_GET['tag']) {
$this->crumb(AWS_APP::lang()->_t('标签') . ': ' . $_GET['tag'], '/favorite/tag-' . $_GET['tag']);
}
//边栏可能感兴趣的人或话题
if (TPL::is_output('block/sidebar_recommend_users_topics.tpl.htm', 'favorite/index')) {
$recommend_users_topics = $this->model('module')->recommend_users_topics($this->user_id);
TPL::assign('sidebar_recommend_users_topics', $recommend_users_topics);
}
if ($action_list = $this->model('favorite')->get_item_list($_GET['tag'], $this->user_id, calc_page_limit($_GET['page'], get_setting('contents_per_page')))) {
foreach ($action_list as $key => $val) {
$item_ids[] = $val['item_id'];
}
TPL::assign('list', $action_list);
} else {
if (!$_GET['page'] or $_GET['page'] == 1) {
$this->model('favorite')->remove_favorite_tag(null, null, $_GET['tag'], $this->user_id);
}
}
if ($item_ids) {
$favorite_items_tags = $this->model('favorite')->get_favorite_items_tags_by_item_id($this->user_id, $item_ids);
TPL::assign('favorite_items_tags', $favorite_items_tags);
}
TPL::assign('favorite_tags', $this->model('favorite')->get_favorite_tags($this->user_id));
TPL::assign('pagination', AWS_APP::pagination()->initialize(array('base_url' => get_js_url('/favorite/tag-' . $_GET['tag']), 'total_rows' => $this->model('favorite')->count_favorite_items($this->user_id, $_GET['tag']), 'per_page' => get_setting('contents_per_page')))->create_links());
TPL::output('favorite/index');
}
示例2: search_topics
public function search_topics($q, $page, $limit = 20)
{
if (is_array($q)) {
$q = implode('', $q);
}
if ($result = $this->fetch_all('topic', "topic_title LIKE '" . $this->quote($q) . "%' AND merged_id = 0", null, calc_page_limit($page, $limit))) {
foreach ($result as $key => $val) {
if (!$val['url_token']) {
$result[$key]['url_token'] = urlencode($val['topic_title']);
}
}
}
return $result;
}
示例3: favorite_list_action
public function favorite_list_action()
{
if ($_GET['tag']) {
$this->crumb(AWS_APP::lang()->_t('标签') . ': ' . $_GET['tag'], '/favorite/tag-' . $_GET['tag']);
}
if ($action_list = $this->model('favorite')->get_item_list($_GET['tag'], $this->user_id, calc_page_limit($_GET['page'], get_setting('contents_per_page')))) {
foreach ($action_list as $key => $val) {
$item_ids[] = $val['item_id'];
}
TPL::assign('list', $action_list);
} else {
if (!$_GET['page'] or $_GET['page'] == 1) {
$this->model('favorite')->remove_favorite_tag(null, null, $_GET['tag'], $this->user_id);
}
}
TPL::output('m/ajax/favorite_list');
}
示例4: fetch_answers_list_by_topic_ids
public function fetch_answers_list_by_topic_ids($topic_ids, $page, $limit)
{
if (!is_array($topic_ids)) {
return false;
}
array_walk_recursive($topic_ids, 'intval_string');
$result_cache_key = 'reader_list_by_topic_ids_' . md5(implode('_', $topic_ids) . $page . $limit);
if (!($result = AWS_APP::cache()->get($result_cache_key))) {
$topic_relation_where[] = '`topic_id` IN(' . implode(',', $topic_ids) . ')';
$topic_relation_where[] = "`type` = 'question'";
if ($topic_relation_query = $this->query_all("SELECT item_id FROM " . get_table('topic_relation') . " WHERE " . implode(' AND ', $topic_relation_where))) {
foreach ($topic_relation_query as $key => $val) {
$question_ids[$val['item_id']] = $val['item_id'];
}
}
if (!$question_ids) {
return false;
}
$result = $this->fetch_all('answer', 'question_id IN (' . implode(',', $question_ids) . ') AND add_time > ' . (time() - 86400 * intval(get_setting('reader_questions_last_days'))) . ' AND agree_count >= ' . intval(get_setting('reader_questions_agree_count')), 'add_time DESC', calc_page_limit($page, $limit));
AWS_APP::cache()->set($result_cache_key, $result, get_setting('cache_level_low'));
}
return $result;
}
示例5: index_action
//.........这里部分代码省略.........
}
} else {
$follow_uids[] = 0;
}
$answer_list_where[] = 'uid IN(' . implode($follow_uids, ',') . ')';
$answer_count_where = 'uid IN(' . implode($follow_uids, ',') . ')';
$answer_order_by = 'add_time ASC';
} else {
if ($_GET['sort_key'] == 'add_time') {
$answer_order_by = $_GET['sort_key'] . " " . $_GET['sort'];
} else {
$answer_order_by = "agree_count " . $_GET['sort'] . ", against_count ASC, add_time ASC";
}
}
}
if ($answer_count_where) {
$answer_count = $this->model('answer')->get_answer_count_by_question_id($question_info['question_id'], $answer_count_where);
} else {
$answer_count = $question_info['answer_count'];
}
if (isset($_GET['answer_id']) and (!$this->user_id or $_GET['single'])) {
$answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, 'answer_id = ' . intval($_GET['answer_id']));
} else {
if (!$this->user_id and !$this->user_info['permission']['answer_show']) {
if ($question_info['best_answer']) {
$answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, 'answer_id = ' . intval($question_info['best_answer']));
} else {
$answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, null, 'agree_count DESC');
}
} else {
if ($answer_list_where) {
$answer_list_where = implode(' AND ', $answer_list_where);
}
$answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], calc_page_limit($_GET['page'], 100), $answer_list_where, $answer_order_by);
}
}
// 最佳回复预留
$answers[0] = '';
if (!is_array($answer_list)) {
$answer_list = array();
}
$answer_ids = array();
$answer_uids = array();
foreach ($answer_list as $answer) {
$answer_ids[] = $answer['answer_id'];
$answer_uids[] = $answer['uid'];
if ($answer['has_attach']) {
$has_attach_answer_ids[] = $answer['answer_id'];
}
}
if (!in_array($question_info['best_answer'], $answer_ids) and intval($_GET['page']) < 2) {
$answer_list = array_merge($this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, 'answer_id = ' . $question_info['best_answer']), $answer_list);
}
if ($answer_ids) {
$answer_agree_users = $this->model('answer')->get_vote_user_by_answer_ids($answer_ids);
$answer_vote_status = $this->model('answer')->get_answer_vote_status($answer_ids, $this->user_id);
$answer_users_rated_thanks = $this->model('answer')->users_rated('thanks', $answer_ids, $this->user_id);
$answer_users_rated_uninterested = $this->model('answer')->users_rated('uninterested', $answer_ids, $this->user_id);
$answer_attachs = $this->model('publish')->get_attachs('answer', $has_attach_answer_ids, 'min');
}
foreach ($answer_list as $answer) {
if ($answer['has_attach']) {
$answer['attachs'] = $answer_attachs[$answer['answer_id']];
$answer['insert_attach_ids'] = FORMAT::parse_attachs($answer['answer_content'], true);
}
$answer['user_rated_thanks'] = $answer_users_rated_thanks[$answer['answer_id']];
示例6: people_square_action
public function people_square_action()
{
if (!$_GET['page']) {
$_GET['page'] = 1;
}
$this->crumb(AWS_APP::lang()->_t('用户列表'), '/m/people/');
if ($_GET['feature_id']) {
if ($helpful_users = $this->model('topic')->get_helpful_users_by_topic_ids($this->model('feature')->get_topics_by_feature_id($_GET['feature_id']), get_setting('contents_per_page'), 4)) {
foreach ($helpful_users as $key => $val) {
$users_list[$key] = $val['user_info'];
$users_list[$key]['experience'] = $val['experience'];
foreach ($val['experience'] as $exp_key => $exp_val) {
$users_list[$key]['total_agree_count'] += $exp_val['agree_count'];
}
}
}
} else {
$where = array();
if ($_GET['group_id']) {
$where[] = 'group_id = ' . intval($_GET['group_id']);
}
$users_list = $this->model('account')->get_users_list(implode('', $where), calc_page_limit($_GET['page'], get_setting('contents_per_page')), true, false, 'reputation DESC');
$where[] = 'forbidden = 0 AND group_id <> 3';
TPL::assign('pagination', AWS_APP::pagination()->initialize(array('base_url' => get_js_url('/m/people/group_id-' . $_GET['group_id']), 'total_rows' => $this->model('account')->get_user_count(implode(' AND ', $where)), 'per_page' => get_setting('contents_per_page'), 'num_links' => 1))->create_links());
}
if ($users_list) {
foreach ($users_list as $key => $val) {
if ($val['reputation']) {
$reputation_users_ids[] = $val['uid'];
$users_reputations[$val['uid']] = $val['reputation'];
}
$uids[] = $val['uid'];
}
if (!$_GET['feature_id']) {
$reputation_topics = $this->model('people')->get_users_reputation_topic($reputation_users_ids, $users_reputations, 4);
foreach ($users_list as $key => $val) {
$users_list[$key]['reputation_topics'] = $reputation_topics[$val['uid']];
}
}
if ($uids and $this->user_id) {
$users_follow_check = $this->model('follow')->users_follow_check($this->user_id, $uids);
}
foreach ($users_list as $key => $val) {
$users_list[$key]['focus'] = $users_follow_check[$val['uid']];
}
TPL::assign('users_list', array_values($users_list));
}
if (!$_GET['group_id']) {
TPL::assign('feature_list', $this->model('feature')->get_enabled_feature_list());
}
TPL::assign('custom_group', $this->model('account')->get_user_group_list(0, 1));
TPL::output('m/people_square');
}
示例7: index_action
public function index_action()
{
if (!($question_info = $this->model('question')->get_question_info_by_id($_GET['id']))) {
H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('问题不存在或已被删除')));
}
if (!$_GET['sort'] or $_GET['sort'] != 'ASC') {
$_GET['sort'] = 'DESC';
} else {
$_GET['sort'] = 'ASC';
}
if (get_setting('unfold_question_comments') == 'Y') {
$_GET['comment_unfold'] = 'all';
}
$question_info['redirect'] = $this->model('question')->get_redirect($question_info['question_id']);
if ($question_info['redirect']['target_id']) {
$target_question = $this->model('question')->get_question_info_by_id($question_info['redirect']['target_id']);
}
if (is_digits($_GET['rf']) and $_GET['rf']) {
if ($from_question = $this->model('question')->get_question_info_by_id($_GET['rf'])) {
$redirect_message[] = AWS_APP::lang()->_t('从问题 %s 跳转而来', '<a href="' . get_js_url('/question/' . $_GET['rf'] . '?rf=false') . '">' . $from_question['question_content'] . '</a>');
}
}
if ($question_info['redirect'] and !$_GET['rf']) {
if ($target_question) {
HTTP::redirect('/question/' . $question_info['redirect']['target_id'] . '?rf=' . $question_info['question_id']);
} else {
$redirect_message[] = AWS_APP::lang()->_t('重定向目标问题已被删除, 将不再重定向问题');
}
} else {
if ($question_info['redirect']) {
if ($target_question) {
$message = AWS_APP::lang()->_t('此问题将跳转至') . ' <a href="' . get_js_url('/question/' . $question_info['redirect']['target_id'] . '?rf=' . $question_info['question_id']) . '">' . $target_question['question_content'] . '</a>';
if ($this->user_id and ($this->user_info['permission']['is_administortar'] or $this->user_info['permission']['is_moderator'] or !$this->question_info['lock'] and $this->user_info['permission']['redirect_question'])) {
$message .= ' (<a href="javascript:;" onclick="AWS.ajax_request(G_BASE_URL + \'/question/ajax/redirect/\', \'item_id=' . $question_info['question_id'] . '\');">' . AWS_APP::lang()->_t('撤消重定向') . '</a>)';
}
$redirect_message[] = $message;
} else {
$redirect_message[] = AWS_APP::lang()->_t('重定向目标问题已被删除, 将不再重定向问题');
}
}
}
$question_info['user_info'] = $this->model('account')->get_user_info_by_uid($question_info['published_uid'], true);
if ($_GET['column'] != 'log') {
$this->model('question')->calc_popular_value($question_info['question_id']);
$this->model('question')->update_views($question_info['question_id']);
if (is_digits($_GET['uid'])) {
$answer_list_where[] = 'uid = ' . intval($_GET['uid']);
$answer_count_where = 'uid = ' . intval($_GET['uid']);
} else {
if ($_GET['uid'] == 'focus' and $this->user_id) {
if ($friends = $this->model('follow')->get_user_friends($this->user_id, false)) {
foreach ($friends as $key => $val) {
$follow_uids[] = $val['uid'];
}
} else {
$follow_uids[] = 0;
}
$answer_list_where[] = 'uid IN(' . implode($follow_uids, ',') . ')';
$answer_count_where = 'uid IN(' . implode($follow_uids, ',') . ')';
$answer_order_by = 'add_time ASC';
} else {
if ($_GET['sort_key'] == 'add_time') {
$answer_order_by = $_GET['sort_key'] . " " . $_GET['sort'];
} else {
$answer_order_by = "agree_count " . $_GET['sort'] . ", against_count ASC, add_time ASC";
}
}
}
if ($answer_count_where) {
$answer_count = $this->model('answer')->get_answer_count_by_question_id($question_info['question_id'], $answer_count_where);
} else {
$answer_count = $question_info['answer_count'];
}
if (isset($_GET['answer_id']) and (!$this->user_id or $_GET['single'])) {
$answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, 'answer_id = ' . intval($_GET['answer_id']));
} else {
if (!$this->user_id and !$this->user_info['permission']['answer_show']) {
if ($question_info['best_answer']) {
$answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, 'answer_id = ' . intval($question_info['best_answer']));
} else {
$answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, null, 'agree_count DESC');
}
} else {
if ($answer_list_where) {
$answer_list_where = implode(' AND ', $answer_list_where);
}
$answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], calc_page_limit($_GET['page'], 100), $answer_list_where, $answer_order_by);
}
}
// 最佳回复预留
$answers[0] = '';
if (!is_array($answer_list)) {
$answer_list = array();
}
$answer_ids = array();
$answer_uids = array();
foreach ($answer_list as $answer) {
$answer_ids[] = $answer['answer_id'];
$answer_uids[] = $answer['uid'];
if ($answer['has_attach']) {
//.........这里部分代码省略.........
示例8: get_hot_topics
public function get_hot_topics($days = null, $page = null, $per_page = null, $count = false)
{
$time = is_digits($days) ? ' AND `add_time` > ' . (time() - $days * 24 * 60 * 60) : '';
if ($count) {
$result = $this->query_row('SELECT count(DISTINCT `topic_id`) AS `count` FROM `' . $this->get_table('topic_relation') . '` WHERE `type` = "ticket"' . $time);
return $result['count'];
}
$limit = ($page and $per_page) ? ' LIMIT ' . calc_page_limit($page, $per_page) : '';
$hot_topics_query = $this->query_all('SELECT `topic_id`, count(*) AS `count` FROM `' . $this->get_table('topic_relation') . '` WHERE `type` = "ticket"' . $time . ' GROUP BY `topic_id` ORDER BY `count` DESC' . $limit);
if ($hot_topics_query) {
foreach ($hot_topics_query as $hot_topic) {
$topic_ids[] = $hot_topic['topic_id'];
}
$tickets_query = $this->query_all('SELECT `topic_id`, `item_id` FROM `' . $this->get_table('topic_relation') . '` WHERE `topic_id` IN (' . implode(', ', $topic_ids) . ')');
foreach ($tickets_query as $val) {
$ticket_ids[] = $val['item_id'];
$topic_ticket[$val['topic_id']][] = $val['item_id'];
}
$hot_topics_list = $this->model('topic')->get_topics_by_ids($topic_ids);
$tickets_list = $this->get_tickets_list(array('ids' => $ticket_ids));
$hot_topics = array();
foreach ($hot_topics_query as $val) {
$hot_topics[$val['topic_id']] = $hot_topics_list[$val['topic_id']];
$hot_topics[$val['topic_id']]['tickets_count'] = $val['count'];
$hot_topics[$val['topic_id']]['unassigned_tickets_count'] = 0;
$hot_topics[$val['topic_id']]['pending_tickets_count'] = 0;
$hot_topics[$val['topic_id']]['closed_tickets_count'] = 0;
foreach ($tickets_list as $ticket_info) {
if (in_array($ticket_info['id'], $topic_ticket[$val['topic_id']])) {
if ($ticket_info['status'] == 'closed') {
$hot_topics[$val['topic_id']]['closed_tickets_count']++;
} else {
if ($ticket_info['service']) {
$hot_topics[$val['topic_id']]['pending_tickets_count']++;
} else {
$hot_topics[$val['topic_id']]['unassigned_tickets_count']++;
}
}
}
}
}
}
return $hot_topics;
}
示例9: load_answers_action
function load_answers_action()
{
// 获取问题
if (!($question_info = $this->model('question')->get_question_info_by_id($_GET['question_id']))) {
return;
}
$this->model('question')->calc_popular_value($question_info['question_id']);
$this->model('question')->update_views($question_info['question_id']);
if (!$_GET['sort'] or $_GET['sort'] != 'ASC') {
$_GET['sort'] = 'DESC';
} else {
$_GET['sort'] = 'ASC';
}
if (is_digits($_GET['uid'])) {
$answer_list_where[] = 'uid = ' . intval($_GET['uid']);
$answer_count_where = 'uid = ' . intval($_GET['uid']);
} else {
if ($_GET['uid'] == 'focus' and $this->user_id) {
if ($friends = $this->model('follow')->get_user_friends($this->user_id, false)) {
foreach ($friends as $key => $val) {
$follow_uids[] = $val['uid'];
}
} else {
$follow_uids[] = 0;
}
$answer_list_where[] = 'uid IN(' . implode($follow_uids, ',') . ')';
$answer_count_where = 'uid IN(' . implode($follow_uids, ',') . ')';
$answer_order_by = 'add_time ASC';
} else {
if ($_GET['sort_key'] == 'popularity') {
$answer_order_by = "agree_count " . $_GET['sort'] . ", against_count ASC, add_time ASC";
} else {
$answer_order_by = "add_time " . $_GET['sort'];
}
}
}
if ($answer_count_where) {
$answer_count = $this->model('answer')->get_answer_count_by_question_id($question_info['question_id'], $answer_count_where);
} else {
$answer_count = $question_info['answer_count'];
}
if (isset($_GET['answer_id']) and (!$this->user_id or $_GET['single'])) {
$answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, 'answer_id = ' . intval($_GET['answer_id']));
} else {
if (!$this->user_id and !$this->user_info['permission']['answer_show']) {
if ($question_info['best_answer']) {
$answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, 'answer_id = ' . intval($question_info['best_answer']));
} else {
$answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, null, 'agree_count DESC');
}
} else {
if ($answer_list_where) {
$answer_list_where = implode(' AND ', $answer_list_where);
}
$answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], calc_page_limit($_GET['page'], 100), $answer_list_where, $answer_order_by);
}
}
// 最佳回复预留
$answers[0] = '';
if (!is_array($answer_list)) {
$answer_list = array();
}
$answer_ids = array();
$answer_uids = array();
foreach ($answer_list as $answer) {
$answer_ids[] = $answer['answer_id'];
$answer_uids[] = $answer['uid'];
if ($answer['has_attach']) {
$has_attach_answer_ids[] = $answer['answer_id'];
}
}
if (!in_array($question_info['best_answer'], $answer_ids) and intval($_GET['page']) < 2) {
$answer_list = array_merge($this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, 'answer_id = ' . $question_info['best_answer']), $answer_list);
}
if ($answer_ids) {
$answer_agree_users = $this->model('answer')->get_vote_user_by_answer_ids($answer_ids);
$answer_vote_status = $this->model('answer')->get_answer_vote_status($answer_ids, $this->user_id);
$answer_users_rated_thanks = $this->model('answer')->users_rated('thanks', $answer_ids, $this->user_id);
$answer_users_rated_uninterested = $this->model('answer')->users_rated('uninterested', $answer_ids, $this->user_id);
$answer_attachs = $this->model('publish')->get_attachs('answer', $has_attach_answer_ids, 'min');
}
foreach ($answer_list as $answer) {
if ($answer['has_attach']) {
$answer['attachs'] = $answer_attachs[$answer['answer_id']];
$answer['insert_attach_ids'] = FORMAT::parse_attachs($answer['answer_content'], true);
}
$answer['user_rated_thanks'] = $answer_users_rated_thanks[$answer['answer_id']];
$answer['user_rated_uninterested'] = $answer_users_rated_uninterested[$answer['answer_id']];
$answer['answer_content'] = $this->model('question')->parse_at_user(FORMAT::parse_attachs(nl2br(FORMAT::parse_bbcode($answer['answer_content']))));
$answer['agree_users'] = $answer_agree_users[$answer['answer_id']];
$answer['agree_status'] = $answer_vote_status[$answer['answer_id']];
if ($question_info['best_answer'] == $answer['answer_id'] and intval($_GET['page']) < 2) {
$answers[0] = $answer;
} else {
$answers[] = $answer;
}
// 获取回答评论列表
$comments = $this->model('answer')->get_answer_comments($answer['answer_id']);
$user_infos = $this->model('account')->get_user_info_by_uids(fetch_array_value($comments, 'uid'));
foreach ($comments as $key => $val) {
//.........这里部分代码省略.........
示例10: square_action
public function square_action()
{
if (!$_GET['id'] and !$this->user_id) {
$_GET['id'] = 'hot';
}
if (!$_GET['per_page']) {
$_GET['per_page'] = 10;
}
switch ($_GET['id']) {
default:
case 'focus':
if ($topics_list = $this->model('topic')->get_focus_topic_list($this->user_id, calc_page_limit($_GET['page'], $_GET['per_page']))) {
$topics_list_total_rows = $this->user_info['topic_focus_count'];
foreach ($topics_list as $key => $val) {
$topics_list[$key]['action_list'] = $this->model('posts')->get_posts_list('question', 1, 3, 'new', explode(',', $val['topic_id']));
}
}
$topic_key = array('topic_id', 'topic_title', 'topic_description', 'topic_pic');
if (!empty($topics_list)) {
foreach ($topics_list as $k => $v) {
foreach ($v as $k_k => $v_v) {
if (!in_array($k_k, $topic_key)) {
unset($topics_list[$k][$k_k]);
}
if ($k_k = "topic_pic") {
$topics_list[$k][$k_k] = str_replace('_32_32', '_100_100', $topics_list[$k][$k_k]);
}
}
}
}
H::ajax_json_output(AWS_APP::RSM(array('total_rows' => $topics_list_total_rows, 'rows' => $topics_list), 1, null));
break;
case 'hot':
if (!($topics_list = AWS_APP::cache()->get('square_hot_topic_list_' . intval($_GET['page'])))) {
if ($topics_list = $this->model('topic')->get_topic_list(null, 'discuss_count DESC', $_GET['per_page'], $_GET['page'])) {
$topics_list_total_rows = $this->model('topic')->found_rows();
AWS_APP::cache()->set('square_hot_topic_list_total_rows', $topics_list_total_rows, get_setting('cache_level_low'));
foreach ($topics_list as $key => $val) {
$topics_list[$key]['action_list'] = $this->model('posts')->get_posts_list('question', 1, 3, 'new', explode(',', $val['topic_id']));
}
}
AWS_APP::cache()->set('square_hot_topic_list_' . intval($_GET['page']), $topics_list, get_setting('cache_level_low'));
} else {
$topics_list_total_rows = AWS_APP::cache()->get('square_hot_topic_list_total_rows');
}
$topic_key = array('topic_id', 'topic_title', 'topic_description', 'topic_pic');
if (!empty($topics_list)) {
foreach ($topics_list as $k => $v) {
foreach ($v as $k_k => $v_v) {
if (!in_array($k_k, $topic_key)) {
unset($topics_list[$k][$k_k]);
}
if ($k_k = "topic_pic") {
$topics_list[$k][$k_k] = str_replace('_32_32', '_100_100', $topics_list[$k][$k_k]);
}
}
}
}
H::ajax_json_output(AWS_APP::RSM(array('total_rows' => $topics_list_total_rows, 'rows' => $topics_list), 1, null));
break;
case 'today':
if ($today_topics = rtrim(get_setting('today_topics'), ',')) {
if (!($today_topic = AWS_APP::cache()->get('square_today_topic_' . md5($today_topics)))) {
if ($today_topic = $this->model('topic')->get_topic_by_title(array_random(explode(',', $today_topics)))) {
$today_topic['best_answer_users'] = $this->model('topic')->get_best_answer_users_by_topic_id($today_topic['topic_id'], 5);
$today_topic['questions_list'] = $this->model('posts')->get_posts_list('question', 1, 3, 'new', explode(',', $today_topic['topic_id']));
AWS_APP::cache()->set('square_today_topic_' . md5($today_topics), $today_topic, strtotime('Tomorrow') - time());
}
}
}
$topic_key = array('topic_id', 'topic_title', 'topic_description', 'topic_pic');
if (!empty($topics_list)) {
foreach ($topics_list as $k => $v) {
foreach ($v as $k_k => $v_v) {
if (!in_array($k_k, $topic_key)) {
unset($topics_list[$k][$k_k]);
}
if ($k_k = "topic_pic") {
$topics_list[$k][$k_k] = str_replace('_32_32', '_100_100', $topics_list[$k][$k_k]);
}
}
}
}
H::ajax_json_output(AWS_APP::RSM(array('total_rows' => $topics_list_total_rows, 'rows' => $topics_list), 1, null));
break;
break;
}
}
示例11: index_square_action
public function index_square_action()
{
if (is_mobile()) {
HTTP::redirect('/m/topic/');
}
if ($today_topics = rtrim(get_setting('today_topics'), ',')) {
if (!($today_topic = AWS_APP::cache()->get('square_today_topic_' . md5($today_topics)))) {
if ($today_topic = $this->model('topic')->get_topic_by_title(array_random(explode(',', $today_topics)))) {
$today_topic['best_answer_users'] = $this->model('topic')->get_best_answer_users_by_topic_id($today_topic['topic_id'], 5);
$today_topic['questions_list'] = $this->model('posts')->get_posts_list('question', 1, 3, 'new', explode(',', $today_topic['topic_id']));
AWS_APP::cache()->set('square_today_topic_' . md5($today_topics), $today_topic, strtotime('Tomorrow') - time());
}
}
TPL::assign('today_topic', $today_topic);
}
switch ($_GET['channel']) {
case 'focus':
if ($topics_list = $this->model('topic')->get_focus_topic_list($this->user_id, calc_page_limit($_GET['page'], 20))) {
$topics_list_total_rows = $this->user_info['topic_focus_count'];
}
TPL::assign('topics_list', $topics_list);
break;
default:
case 'hot':
switch ($_GET['day']) {
case 'month':
$order = 'discuss_count_last_month DESC';
break;
case 'week':
$order = 'discuss_count_last_week DESC';
break;
default:
$order = 'discuss_count DESC';
break;
}
$cache_key = 'square_hot_topic_list' . md5($order) . '_' . intval($_GET['page']);
if (!($topics_list = AWS_APP::cache()->get($cache_key))) {
if ($topics_list = $this->model('topic')->get_topic_list(null, $order, 20, $_GET['page'])) {
$topics_list_total_rows = $this->model('topic')->found_rows();
AWS_APP::cache()->set('square_hot_topic_list_total_rows', $topics_list_total_rows, get_setting('cache_level_low'));
}
AWS_APP::cache()->set($cache_key, $topics_list, get_setting('cache_level_low'));
} else {
$topics_list_total_rows = AWS_APP::cache()->get('square_hot_topic_list_total_rows');
}
TPL::assign('topics_list', $topics_list);
break;
case 'topic':
if (!($topics_list = AWS_APP::cache()->get('square_parent_topics_topic_list_' . intval($_GET['topic_id']) . '_' . intval($_GET['page'])))) {
$topic_ids[] = intval($_GET['topic_id']);
if ($child_topic_ids = $this->model('topic')->get_child_topic_ids($_GET['topic_id'])) {
$topic_ids = array_merge($child_topic_ids, $topic_ids);
}
if ($topics_list = $this->model('topic')->get_topic_list('topic_id IN(' . implode(',', $topic_ids) . ') AND merged_id = 0', 'discuss_count DESC', 20, $_GET['page'])) {
$topics_list_total_rows = $this->model('topic')->found_rows();
AWS_APP::cache()->set('square_parent_topics_topic_list_' . intval($_GET['topic_id']) . '_total_rows', $topics_list_total_rows, get_setting('cache_level_low'));
}
AWS_APP::cache()->set('square_parent_topics_topic_list_' . intval($_GET['topic_id']) . '_' . intval($_GET['page']), $topics_list, get_setting('cache_level_low'));
} else {
$topics_list_total_rows = AWS_APP::cache()->get('square_parent_topics_topic_list_' . intval($_GET['topic_id']) . '_total_rows');
}
TPL::assign('topics_list', $topics_list);
break;
}
TPL::assign('parent_topics', $this->model('topic')->get_parent_topics());
TPL::assign('new_topics', $this->model('topic')->get_topic_list(null, 'topic_id DESC', 10));
TPL::assign('pagination', AWS_APP::pagination()->initialize(array('base_url' => get_js_url('/topic/channel-' . $_GET['channel'] . '__topic_id-' . $_GET['topic_id'] . '__day-' . $_GET['day']), 'total_rows' => $topics_list_total_rows, 'per_page' => 20))->create_links());
$this->crumb(AWS_APP::lang()->_t('话题广场'), '/topic/');
TPL::output('topic/square');
}
示例12: get_project_list_by_topic_ids
public function get_project_list_by_topic_ids($topic_ids, $order_by = 'add_time DESC', $page = 1, $per_page = 10)
{
if (!is_array($topic_ids)) {
return false;
}
array_walk_recursive($topic_ids, 'intval_string');
$result_cache_key = 'project_list_by_topic_ids_' . implode('_', $topic_ids) . '_' . md5($answer_count . $category_id . $order_by . $is_recommend . $page . $per_page . $post_type);
$found_rows_cache_key = 'project_list_by_topic_ids_found_rows_' . implode('_', $topic_ids) . '_' . md5($answer_count . $category_id . $is_recommend . $per_page . $post_type);
$where[] = 'topic_relation.topic_id IN(' . implode(',', $topic_ids) . ')';
$on_query[] = 'project.id = topic_relation.item_id';
$on_query[] = "topic_relation.type = 'project'";
$on_query[] = 'project.approved = 1';
$on_query[] = "project.status = 'ONLINE'";
if (!($found_rows = AWS_APP::cache()->get($found_rows_cache_key))) {
$_found_rows = $this->query_row('SELECT COUNT(DISTINCT project.id) AS count FROM ' . $this->get_table('project') . ' AS project LEFT JOIN ' . $this->get_table('topic_relation') . " AS topic_relation ON " . implode(' AND ', $on_query) . " WHERE " . implode(' AND ', $where));
$found_rows = $_found_rows['count'];
AWS_APP::cache()->set($found_rows_cache_key, $found_rows, get_setting('cache_level_high'));
}
$this->project_list_total = $found_rows;
if (!($result = AWS_APP::cache()->get($result_cache_key))) {
$result = $this->query_all('SELECT project.* FROM ' . $this->get_table('project') . ' AS project LEFT JOIN ' . $this->get_table('topic_relation') . " AS topic_relation ON " . implode(' AND ', $on_query) . " WHERE " . implode(' AND ', $where) . ' GROUP BY project.id ORDER BY project.' . $order_by, calc_page_limit($page, $per_page));
AWS_APP::cache()->set($result_cache_key, $result, get_setting('cache_level_high'));
}
return $result;
}
示例13: index_square_action
public function index_square_action()
{
if (!$_GET['page']) {
$_GET['page'] = 1;
}
$this->crumb(AWS_APP::lang()->_t('用户列表'), '/people/');
if ($_GET['topic_id']) {
if ($helpful_users = $this->model('topic')->get_helpful_users_by_topic_ids($this->model('topic')->get_child_topic_ids($_GET['topic_id']), get_setting('contents_per_page'), 4)) {
foreach ($helpful_users as $key => $val) {
$users_list[$key] = $val['user_info'];
$users_list[$key]['experience'] = $val['experience'];
foreach ($val['experience'] as $exp_key => $exp_val) {
$users_list[$key]['total_agree_count'] += $exp_val['agree_count'];
}
}
}
} else {
$where = array();
if ($_GET['group_id']) {
$where[] = 'group_id = ' . intval($_GET['group_id']);
}
if ($_GET['sort_type']) {
switch ($_GET['sort_type']) {
case 'passed':
$sort_key = 'question_quiz_count_passed DESC';
break;
case 'poft':
$sort_key = 'question_quiz_poft_ratio DESC';
break;
case 'question_count':
$sort_key = 'question_count DESC';
break;
case 'quiz_count':
$sort_key = 'question_quiz_count_total DESC';
break;
case 'integral':
$sort_key = 'integral DESC';
break;
default:
$sort_key = 'question_quiz_success_ratio DESC';
break;
}
} else {
$sort_key = 'question_quiz_success_ratio DESC';
}
$where[] = 'forbidden = 0 AND group_id >=4 AND group_id < 99';
$users_list = $this->model('account')->get_users_list(implode('', $where), calc_page_limit($_GET['page'], get_setting('user_rank_list_perpage')), true, false, $sort_key);
TPL::assign('pagination', AWS_APP::pagination()->initialize(array('base_url' => get_js_url('/people/sort_type-' . $_GET['sort_type'] . '__group_id-' . $_GET['group_id']), 'total_rows' => $this->model('account')->get_user_count(implode(' AND ', $where)), 'per_page' => get_setting('user_rank_list_perpage')))->create_links());
}
if ($users_list) {
foreach ($users_list as $key => $val) {
if ($val['reputation']) {
$reputation_users_ids[] = $val['uid'];
$users_reputations[$val['uid']] = $val['reputation'];
}
$uids[] = $val['uid'];
}
if (!$_GET['topic_id']) {
$reputation_topics = $this->model('people')->get_users_reputation_topic($reputation_users_ids, $users_reputations, 5);
foreach ($users_list as $key => $val) {
$users_list[$key]['reputation_topics'] = $reputation_topics[$val['uid']];
}
}
if ($uids and $this->user_id) {
$users_follow_check = $this->model('follow')->users_follow_check($this->user_id, $uids);
foreach ($users_list as $key => $val) {
$users_list[$key]['focus'] = $users_follow_check[$val['uid']];
}
}
TPL::assign('users_list', array_values($users_list));
}
if (!$_GET['group_id']) {
TPL::assign('parent_topics', $this->model('topic')->get_parent_topics());
}
TPL::assign('custom_group', $this->model('account')->get_user_group_list(0, 1));
if ($_GET['sort_type']) {
TPL::assign('sort_type', $_GET['sort_type']);
}
TPL::import_js('js/app/rank.js');
TPL::output('people/square');
}
示例14: favorite_action
public function favorite_action()
{
if ($action_list = $this->model('favorite')->get_item_list($_GET['tag'], $this->user_id, calc_page_limit($_GET['page'], get_setting('contents_per_page')))) {
foreach ($action_list as $key => $val) {
$item_ids[] = $val['item_id'];
}
} else {
if (!$_GET['page'] or $_GET['page'] == 1) {
$this->model('favorite')->remove_favorite_tag(null, null, $_GET['tag'], $this->user_id);
}
}
H::ajax_json_output(AWS_APP::RSM(array('total_rows' => count($action_list), 'rows' => $action_list), 1, null));
}
示例15: message_parser
public function message_parser($input_message, $param = null)
{
$message_code = strtoupper(trim($input_message['content']));
if (cjk_strlen($message_code) < 2) {
return false;
}
if (!$param) {
$param = 1;
}
switch ($message_code) {
default:
if (cjk_strlen($input_message['content']) > 1 and substr($input_message['content'], 0, 1) == '@') {
if ($user_info = $this->model('account')->get_user_info_by_username(substr($input_message['content'], 1), true)) {
$response_message[] = array('title' => $user_info['signature'], 'link' => get_js_url('/m/people/' . $user_info['url_token']), 'image_file' => get_avatar_url($user_info['uid'], ''));
if ($user_actions = $this->model('actions')->get_user_actions($user_info['uid'], calc_page_limit($param, 4), 101)) {
foreach ($user_actions as $key => $val) {
$response_message[] = array('title' => $val['question_info']['question_content'], 'link' => get_js_url('/m/question/' . $val['question_info']['question_id']), 'image_file' => get_avatar_url($val['question_info']['published_uid'], 'max'));
}
}
}
} else {
if ($topic_info = $this->model('topic')->get_topic_by_title($input_message['content'])) {
$response_message[] = array('title' => $topic_info['topic_title'], 'link' => get_js_url('/m/topic/' . $topic_info['url_token']), 'image_file' => get_topic_pic_url('', $topic_info['topic_pic']));
if ($topic_posts = $this->model('posts')->get_posts_list(null, $param, 4, 'new', array($topic_info['topic_id']))) {
foreach ($topic_posts as $key => $val) {
if ($val['uid']) {
$image_file = get_avatar_url($val['uid'], 'max');
$title = $val['title'];
$link = get_js_url('/m/article/' . $val['id']);
} else {
$image_file = get_avatar_url($val['published_uid'], 'max');
$title = $val['question_content'];
$link = get_js_url('/m/question/' . $val['question_id']);
}
$response_message[] = array('title' => $title, 'link' => $link, 'image_file' => $image_file);
}
}
} else {
if ($search_result = $this->model('search')->search_questions($input_message['content'], null, $param, 5)) {
foreach ($search_result as $key => $val) {
if (!$response_message) {
$image_file = AWS_APP::config()->get('weixin')->default_list_image;
} else {
$image_file = get_avatar_url($val['published_uid'], 'max');
}
$response_message[] = array('title' => $val['question_content'], 'link' => get_js_url('/m/question/' . $val['question_id']), 'image_file' => $image_file);
}
}
}
}
break;
case 'NEW_ARTICLE':
if ($input_message['param']) {
$child_param = explode('_', $input_message['param']);
switch ($child_param[0]) {
case 'FEATURE':
$topic_ids = $this->model('feature')->get_topics_by_feature_id($child_param[1]);
break;
}
}
if ($topic_ids) {
$article_list = $this->model('article')->get_articles_list_by_topic_ids($param, 5, 'add_time DESC', $topic_ids);
} else {
$article_list = $this->model('article')->get_articles_list(null, $param, 5, 'add_time DESC');
}
foreach ($article_list as $key => $val) {
if (!$response_message) {
if (!($image_file = $this->get_client_list_image_by_command('COMMAND_' . $message_code))) {
$image_file = AWS_APP::config()->get('weixin')->default_list_image;
}
} else {
$image_file = get_avatar_url($val['uid'], 'max');
}
$response_message[] = array('title' => $val['title'], 'link' => get_js_url('/m/article/' . $val['id']), 'image_file' => $image_file);
}
break;
case 'HOT_QUESTION':
if ($input_message['param']) {
$child_param = explode('_', $input_message['param']);
switch ($child_param[0]) {
case 'CATEGORY':
$category_id = intval($child_param[1]);
break;
case 'FEATURE':
$topic_ids = $this->model('feature')->get_topics_by_feature_id($child_param[1]);
break;
}
}
if ($question_list = $this->model('posts')->get_hot_posts('question', $category_id, $topic_ids, 7, $param, 5)) {
foreach ($question_list as $key => $val) {
if (!$response_message) {
if (!($image_file = $this->get_client_list_image_by_command('COMMAND_' . $message_code))) {
$image_file = AWS_APP::config()->get('weixin')->default_list_image;
}
} else {
$image_file = get_avatar_url($val['published_uid'], 'max');
}
$response_message[] = array('title' => $val['question_content'], 'link' => get_js_url('/m/question/' . $val['question_id']), 'image_file' => $image_file);
}
} else {
//.........这里部分代码省略.........