public function index_action() { if (!$this->user_id) { HTTP::redirect('/explore/'); } if (!$this->user_info['email']) { HTTP::redirect('/account/complete_profile/'); } // 边栏可能感兴趣的人或话题 if (TPL::is_output('block/sidebar_recommend_users_topics.tpl.htm', 'home/index')) { $recommend_users_topics = $this->model('module')->recommend_users_topics($this->user_id); TPL::assign('sidebar_recommend_users_topics', $recommend_users_topics); } // 边栏热门用户 if (TPL::is_output('block/sidebar_hot_users.tpl.htm', 'home/index')) { $sidebar_hot_users = $this->model('module')->sidebar_hot_users($this->user_id); TPL::assign('sidebar_hot_users', $sidebar_hot_users); } $this->crumb(AWS_APP::lang()->_t('动态'), '/home/'); TPL::import_js('js/app/index.js'); if ($_GET['first_login']) { TPL::import_js('js/ajaxupload.js'); } TPL::output('home/index'); }
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'); }
public function index_square_action() { $this->crumb(AWS_APP::lang()->_t('问题'), '/question/'); // 导航 if (TPL::is_output('block/content_nav_menu.tpl.htm', 'question/square')) { TPL::assign('content_nav_menu', $this->model('menu')->get_nav_menu_list('question')); } //边栏可能感兴趣的人 if (TPL::is_output('block/sidebar_recommend_users_topics.tpl.htm', 'question/square')) { TPL::assign('sidebar_recommend_users_topics', $this->model('module')->recommend_users_topics($this->user_id)); } //边栏热门用户 if (TPL::is_output('block/sidebar_hot_users.tpl.htm', 'question/square')) { TPL::assign('sidebar_hot_users', $this->model('module')->sidebar_hot_users($this->user_id, 5)); } //边栏热门话题 if (TPL::is_output('block/sidebar_hot_topics.tpl.htm', 'question/square')) { TPL::assign('sidebar_hot_topics', $this->model('module')->sidebar_hot_topics($_GET['category'])); } //边栏专题 if (TPL::is_output('block/sidebar_feature.tpl.htm', 'question/square')) { TPL::assign('feature_list', $this->model('module')->feature_list()); } if ($_GET['category']) { if (is_digits($_GET['category'])) { $category_info = $this->model('system')->get_category_info($_GET['category']); } else { $category_info = $this->model('system')->get_category_info_by_url_token($_GET['category']); } } if ($category_info) { TPL::assign('category_info', $category_info); $this->crumb($category_info['title'], '/question/category-' . $category_info['id']); $meta_description = $category_info['title']; if ($category_info['description']) { $meta_description .= ' - ' . $category_info['description']; } TPL::set_meta('description', $meta_description); } if ($_GET['feature_id']) { $feature_info = $this->model('feature')->get_feature_by_id($_GET['feature_id']); TPL::assign('feature_info', $feature_info); } if ($feature_info['id']) { $topic_ids = $this->model('feature')->get_topics_by_feature_id($feature_info['id']); } if (!$_GET['sort_type']) { $_GET['sort_type'] = 'new'; } if ($_GET['sort_type'] == 'hot') { $question_list = $this->model('posts')->get_hot_posts('question', $category_info['id'], $topic_ids, $_GET['day'], $_GET['page'], get_setting('contents_per_page')); } else { $question_list = $this->model('posts')->get_posts_list('question', $_GET['page'], get_setting('contents_per_page'), $_GET['sort_type'], $topic_ids, $category_info['id'], $_GET['answer_count'], $_GET['day'], $_GET['is_recommend']); } if ($question_list) { foreach ($question_list as $key => $val) { if ($val['answer_count']) { $question_list[$key]['answer_users'] = $this->model('question')->get_answer_users_by_question_id($val['question_id'], 2, $val['published_uid']); } } } TPL::assign('pagination', AWS_APP::pagination()->initialize(array('base_url' => get_js_url('/question/sort_type-' . preg_replace("/[\\(\\)\\.;']/", '', $_GET['sort_type']) . '__category-' . $category_info['id'] . '__day-' . intval($_GET['day']) . '__is_recommend-' . $_GET['is_recommend']) . '__feature_id-' . $feature_info['id'], 'total_rows' => $this->model('posts')->get_posts_list_total(), 'per_page' => get_setting('contents_per_page')))->create_links()); TPL::assign('posts_list', $question_list); TPL::assign('question_list_bit', TPL::output('explore/ajax/list', false)); TPL::output('question/square'); }
public function index_action() { if (is_digits($_GET['id'])) { if (!($topic_info = $this->model('topic')->get_topic_by_id($_GET['id']))) { $topic_info = $this->model('topic')->get_topic_by_title($_GET['id']); } } else { if (!($topic_info = $this->model('topic')->get_topic_by_title($_GET['id']))) { $topic_info = $this->model('topic')->get_topic_by_url_token($_GET['id']); } } if (!$topic_info) { H::redirect_msg(AWS_APP::lang()->_t('专题不存在'), '/'); } // if ($topic_info['merged_id'] AND $topic_info['merged_id'] != $topic_info['topic_id']) // { // if ($this->model('topic')->get_topic_by_id($topic_info['merged_id'])) // { // HTTP::redirect('/topic/' . $topic_info['merged_id'] . '?rf=' . $topic_info['topic_id']); // } // else // { // $this->model('topic')->remove_merge_topic($topic_info['topic_id'], $topic_info['merged_id']); // } // } // if (urldecode($topic_info['url_token']) != $_GET['id']) // { // HTTP::redirect('/topic/' . $topic_info['url_token'] . '?rf=' . $_GET['rf']); // } // if (is_digits($_GET['rf']) and $_GET['rf']) // { // if ($from_topic = $this->model('topic')->get_topic_by_id($_GET['rf'])) // { // $redirect_message[] = AWS_APP::lang()->_t('话题 (%s) 已与当前话题合并', $from_topic['topic_title']); // } // } if ($topic_info['seo_title']) { TPL::assign('page_title', $topic_info['seo_title']); } else { $this->crumb($topic_info['topic_title'], '/topic/' . $topic_info['url_token']); } if ($this->user_id) { $topic_info['has_focus'] = $this->model('topic')->has_focus_topic($this->user_id, $topic_info['topic_id']); } if ($topic_info['topic_description']) { TPL::set_meta('description', $topic_info['topic_title'] . ' - ' . cjk_substr(str_replace("\r\n", ' ', strip_tags($topic_info['topic_description'])), 0, 128, 'UTF-8', '...')); } $topic_info['topic_description'] = nl2br(FORMAT::parse_bbcode($topic_info['topic_description'])); //是否首页精选 $topic_info['is_recommend_homepage'] = $this->model('recommend')->recommend_homepage_check('topic', $topic_info['topic_id']); TPL::assign('topic_info', $topic_info); // TPL::assign('best_answer_users', $this->model('topic')->get_best_answer_users_by_topic_id($topic_info['topic_id'], 5)); switch ($topic_info['model_type']) { default: // $related_topics_ids = array(); // if ($related_topics = $this->model('topic')->related_topics($topic_info['topic_id'])) // { // foreach ($related_topics AS $key => $val) // { // $related_topics_ids[$val['topic_id']] = $val['topic_id']; // } // } // if ($child_topic_ids = $this->model('topic')->get_child_topic_ids($topic_info['topic_id'])) // { // foreach ($child_topic_ids AS $key => $topic_id) // { // $related_topics_ids[$topic_id] = $topic_id; // } // } // TPL::assign('related_topics', $related_topics); // $log_list = ACTION_LOG::get_action_by_event_id($topic_info['topic_id'], 10, ACTION_LOG::CATEGORY_TOPIC, implode(',', array( // ACTION_LOG::ADD_TOPIC, // ACTION_LOG::MOD_TOPIC, // ACTION_LOG::MOD_TOPIC_DESCRI, // ACTION_LOG::MOD_TOPIC_PIC, // ACTION_LOG::DELETE_TOPIC, // ACTION_LOG::ADD_RELATED_TOPIC, // ACTION_LOG::DELETE_RELATED_TOPIC // )), -1); // $log_list = $this->model('topic')->analysis_log($log_list); // $contents_topic_id = $topic_info['topic_id']; // $contents_topic_title = $topic_info['topic_title']; // if ($merged_topics = $this->model('topic')->get_merged_topic_ids($topic_info['topic_id'])) // { // foreach ($merged_topics AS $key => $val) // { // $merged_topic_ids[] = $val['source_id']; // } // $contents_topic_id .= ',' . implode(',', $merged_topic_ids); // if ($merged_topics_info = $this->model('topic')->get_topics_by_ids($merged_topic_ids)) // { // foreach($merged_topics_info AS $key => $val) // { // $merged_topic_title[] = $val['topic_title']; // } // } // if ($merged_topic_title) // { // $contents_topic_title .= ',' . implode(',', $merged_topic_title); // } // } // // $contents_related_topic_ids = array_merge($related_topics_ids, explode(',', $contents_topic_id)); // // TPL::assign('contents_related_topic_ids', implode(',', $contents_related_topic_ids)); // // if ($posts_list = $this->model('posts')->get_posts_list(null, 1, get_setting('contents_per_page'), 'new', $contents_related_topic_ids)) // // { // // foreach ($posts_list AS $key => $val) // // { // // if ($val['answer_count']) // // { // // $posts_list[$key]['answer_users'] = $this->model('question')->get_answer_users_by_question_id($val['question_id'], 2, $val['published_uid']); // // } // // } // // } // // TPL::assign('posts_list', $posts_list); // // TPL::assign('all_list_bit', TPL::output('explore/ajax/list', false)); // // if ($posts_list = $this->model('posts')->get_posts_list(null, 1, get_setting('contents_per_page'), null, $contents_related_topic_ids, null, null, 30, true)) // // { // // foreach ($posts_list AS $key => $val) // // { // // if ($val['answer_count']) // // { // // $posts_list[$key]['answer_users'] = $this->model('question')->get_answer_users_by_question_id($val['question_id'], 2, $val['published_uid']); // // } // // } // // } // 问题列表 $question_list = $this->model('topic')->get_question_list_by_topic($topic_info['topic_id'], $_GET['page'], get_setting('contents_per_page')); if ($question_list) { foreach ($question_list as $key => $val) { $this->model('question')->load_list_question_info($question_list[$key], $val, $this->user_id); } } TPL::assign('pagination', AWS_APP::pagination()->initialize(array('base_url' => get_js_url('/topic/id-' . $topic_info['topic_id'] . '__page-', $_GET['page']), 'total_rows' => $this->model('topic')->get_question_list_total(), 'per_page' => get_setting('contents_per_page'), 'num_links' => 2))->create_links()); TPL::assign('question_list', $question_list); //边栏热门话题 if (TPL::is_output('block/sidebar_hot_topics.tpl.htm', 'question/square')) { TPL::assign('sidebar_hot_topics', $this->model('module')->sidebar_hot_topics($_GET['category'], 4)); } // TPL::assign('topic_recommend_list', $posts_list); // TPL::assign('posts_list', $posts_list); // TPL::assign('recommend_list_bit', TPL::output('explore/ajax/list', false)); // TPL::assign('list', $this->model('topic')->get_topic_best_answer_action_list($contents_topic_id, $this->user_id, get_setting('contents_per_page'))); // TPL::assign('best_questions_list_bit', TPL::output('home/ajax/index_actions', false)); // TPL::assign('posts_list', $this->model('posts')->get_posts_list('question', 1, get_setting('contents_per_page'), 'new', explode(',', $contents_topic_id))); // TPL::assign('all_questions_list_bit', TPL::output('explore/ajax/list', false)); // TPL::assign('posts_list', $this->model('posts')->get_posts_list('article', 1, get_setting('contents_per_page'), 'new', explode(',', $contents_topic_id))); // TPL::assign('articles_list_bit', TPL::output('explore/ajax/list', false)); // TPL::assign('contents_topic_id', $contents_topic_id); // TPL::assign('contents_topic_title', $contents_topic_title); // TPL::assign('log_list', $log_list); // TPL::assign('redirect_message', $redirect_message); if ($topic_info['parent_id']) { TPL::assign('parent_topic_info', $this->model('topic')->get_topic_by_id($topic_info['parent_id'])); } TPL::output('topic/index'); break; } }
public function index_square_action() { if (is_mobile()) { HTTP::redirect('/m/article/'); } $this->crumb(AWS_APP::lang()->_t('文章'), '/article/'); if ($_GET['category']) { if (is_digits($_GET['category'])) { $category_info = $this->model('system')->get_category_info($_GET['category']); } else { $category_info = $this->model('system')->get_category_info_by_url_token($_GET['category']); } } if ($_GET['feature_id']) { $article_list = $this->model('article')->get_articles_list_by_topic_ids($_GET['page'], get_setting('contents_per_page'), 'add_time DESC', $this->model('feature')->get_topics_by_feature_id($_GET['feature_id'])); $article_list_total = $this->model('article')->article_list_total; if ($feature_info = $this->model('feature')->get_feature_by_id($_GET['feature_id'])) { $this->crumb($feature_info['title'], '/article/feature_id-' . $feature_info['id']); TPL::assign('feature_info', $feature_info); } } else { $article_list = $this->model('article')->get_articles_list($category_info['id'], $_GET['page'], get_setting('contents_per_page'), 'add_time DESC'); $article_list_total = $this->model('article')->found_rows(); } if ($article_list) { foreach ($article_list as $key => $val) { $article_ids[] = $val['id']; $article_uids[$val['uid']] = $val['uid']; } $article_topics = $this->model('topic')->get_topics_by_item_ids($article_ids, 'article'); $article_users_info = $this->model('account')->get_user_info_by_uids($article_uids); foreach ($article_list as $key => $val) { $article_list[$key]['user_info'] = $article_users_info[$val['uid']]; } } // 导航 if (TPL::is_output('block/content_nav_menu.tpl.htm', 'article/square')) { TPL::assign('content_nav_menu', $this->model('menu')->get_nav_menu_list('article')); } //边栏热门话题 if (TPL::is_output('block/sidebar_hot_topics.tpl.htm', 'article/square')) { TPL::assign('sidebar_hot_topics', $this->model('module')->sidebar_hot_topics($category_info['id'])); } if ($category_info) { TPL::assign('category_info', $category_info); $this->crumb($category_info['title'], '/article/category-' . $category_info['id']); $meta_description = $category_info['title']; if ($category_info['description']) { $meta_description .= ' - ' . $category_info['description']; } TPL::set_meta('description', $meta_description); } TPL::assign('article_list', $article_list); TPL::assign('article_topics', $article_topics); TPL::assign('hot_articles', $this->model('article')->get_articles_list(null, 1, 10, 'votes DESC')); TPL::assign('pagination', AWS_APP::pagination()->initialize(array('base_url' => get_js_url('/article/category_id-' . $_GET['category_id'] . '__feature_id-' . $_GET['feature_id']), 'total_rows' => $article_list_total, 'per_page' => get_setting('contents_per_page')))->create_links()); TPL::output('article/square'); }
public function index_action() { if (is_mobile()) { HTTP::redirect('/m/explore/' . $_GET['id']); } if ($this->user_id) { $this->crumb(AWS_APP::lang()->_t('发现'), '/question'); if (!$this->user_info['email']) { HTTP::redirect('/account/complete_profile/'); } } if ($_GET['category']) { if (is_digits($_GET['category'])) { $category_info = $this->model('system')->get_category_info($_GET['category']); } else { $category_info = $this->model('system')->get_category_info_by_url_token($_GET['category']); } } if ($category_info) { TPL::assign('category_info', $category_info); $this->crumb($category_info['title'], '/category-' . $category_info['id']); $meta_description = $category_info['title']; if ($category_info['description']) { $meta_description .= ' - ' . $category_info['description']; } TPL::set_meta('description', $meta_description); } // 导航 if (TPL::is_output('block/content_nav_menu.tpl.htm', 'explore/index')) { TPL::assign('content_nav_menu', $this->model('menu')->get_nav_menu_list('explore')); } // 边栏可能感兴趣的人 if (TPL::is_output('block/sidebar_recommend_users_topics.tpl.htm', 'explore/index')) { if ($this->user_id) { TPL::assign('sidebar_recommend_users_topics', $this->model('module')->recommend_users_topics($this->user_id)); } } // 边栏热门用户 if (TPL::is_output('block/sidebar_hot_users.tpl.htm', 'explore/index')) { TPL::assign('sidebar_hot_users', $this->model('module')->sidebar_hot_users($this->user_id, 8)); } // 边栏热门话题 if (TPL::is_output('block/sidebar_hot_topics.tpl.htm', 'explore/index')) { TPL::assign('sidebar_hot_topics', $this->model('module')->sidebar_hot_topics($category_info['id'])); } // 边栏专题 if (TPL::is_output('block/sidebar_feature.tpl.htm', 'explore/index')) { TPL::assign('feature_list', $this->model('module')->feature_list()); } //最近所有热门 if (TPL::is_output('block/near_hots_square.tpl.htm', 'explore/index')) { $posts_list = $this->model('posts')->get_hot_posts(null, $category_info['id'], null, $_GET['day'], $_GET['page'], 12); TPL::assign('near_posts_list', $posts_list); } if (!$_GET['sort_type'] and !$_GET['is_recommend']) { $_GET['sort_type'] = 'new'; } if ($_GET['sort_type'] !== 'new' && isset($_GET['sort_type']) or isset($_GET['is_recommend'])) { Header("HTTP/1.1 301 Moved Permanently"); $url = "/question" . $_SERVER[REQUEST_URI]; HTTP::redirect($url); } else { $posts_list = $this->model('posts')->get_posts_list(null, $_GET['page'], get_setting('contents_per_page'), $_GET['sort_type'], null, $category_info['id'], $_GET['answer_count'], $_GET['day'], $_GET['is_recommend']); } if ($posts_list) { foreach ($posts_list as $key => $val) { if ($val['answer_count']) { $posts_list[$key]['answer_users'] = $this->model('question')->get_answer_users_by_question_id($val['question_id'], 2, $val['published_uid']); } } } TPL::assign('pagination', AWS_APP::pagination()->initialize(array('base_url' => get_js_url('/sort_type-' . preg_replace("/[\\(\\)\\.;']/", '', $_GET['sort_type']) . '__category-' . $category_info['id'] . '__day-' . intval($_GET['day']) . '__is_recommend-' . intval($_GET['is_recommend'])), 'total_rows' => $this->model('posts')->get_posts_list_total(), 'per_page' => get_setting('contents_per_page')))->create_links()); TPL::assign('posts_list', $posts_list); TPL::assign('posts_list_bit', TPL::output('explore/ajax/list', false)); TPL::output('explore/index'); }
public function recommend_action() { if (is_mobile()) { HTTP::redirect('/m/article/'); } $this->crumb(AWS_APP::lang()->_t('推荐文章'), '/article/'); if ($_GET['feature_id']) { $article_list = $this->model('article')->get_articles_list_by_topic_ids($_GET['page'], get_setting('contents_per_page'), 'is_recommend DESC', $this->model('feature')->get_topics_by_feature_id($_GET['feature_id'])); $article_list_total = $this->model('article')->article_list_total; if ($feature_info = $this->model('feature')->get_feature_by_id($_GET['feature_id'])) { $this->crumb($feature_info['title'], '/article/feature_id-' . $feature_info['id']); TPL::assign('feature_info', $feature_info); } } else { $article_list = $this->model('article')->get_articles_list($category_info['id'], $_GET['page'], get_setting('contents_per_page'), 'is_recommend DESC'); $article_list_total = $this->model('article')->found_rows(); } if ($article_list) { foreach ($article_list as $key => $val) { $article_ids[] = $val['id']; $article_uids[$val['uid']] = $val['uid']; } $article_topics = $this->model('topic')->get_topics_by_item_ids($article_ids, 'article'); $article_users_info = $this->model('account')->get_user_info_by_uids($article_uids); foreach ($article_list as $key => $val) { $article_list[$key]['user_info'] = $article_users_info[$val['uid']]; } } if (TPL::is_output('block/sidebar_hot_topics.tpl.htm', 'article/square')) { TPL::assign('sidebar_hot_topics', $this->model('module')->sidebar_hot_topics($category_info['id'])); } TPL::assign('hot_articles', $this->model('article')->get_articles_list(null, 1, 10, 'votes DESC')); TPL::assign('article_list', $article_list); TPL::output('article/square'); }
public function index_square_action() { $this->crumb(AWS_APP::lang()->_t('知识'), '/article/'); if ($_GET['category']) { if (is_digits($_GET['category'])) { $category_info = $this->model('system')->get_category_info($_GET['category']); } else { $category_info = $this->model('system')->get_category_info_by_url_token($_GET['category']); } } if ($_GET['feature_id']) { $article_list = $this->model('article')->get_articles_list_by_topic_ids($_GET['page'], get_setting('contents_per_page'), 'add_time DESC', $this->model('feature')->get_topics_by_feature_id($_GET['feature_id'])); $article_list_total = $this->model('article')->article_list_total; if ($feature_info = $this->model('feature')->get_feature_by_id($_GET['feature_id'])) { $this->crumb($feature_info['title'], '/article/feature_id-' . $feature_info['id']); TPL::assign('feature_info', $feature_info); } } else { $article_list = $this->model('article')->get_articles_list($category_info['id'], $_GET['page'], get_setting('contents_per_page'), 'add_time DESC'); $article_list_total = $this->model('article')->found_rows(); } if ($article_list) { foreach ($article_list as $key => $val) { $article_ids[] = $val['id']; $article_uids[$val['uid']] = $val['uid']; } $article_topics = $this->model('topic')->get_topics_by_item_ids($article_ids, 'article'); $article_users_info = $this->model('account')->get_user_info_by_uids($article_uids); // 获取文章缩略图 $article_attachs = $this->model('publish')->get_attachs('article', $article_ids, 'min'); foreach ($article_list as $key => $val) { $article_list[$key]['user_info'] = $article_users_info[$val['uid']]; if ($val['has_attach']) { $article_list[$key]['attachs'] = $article_attachs[$val['id']]; } // 文章分类信息 $article_list[$key]['category_info'] = $this->model('system')->get_category_info($val['category_id']); } } //边栏热门话题 if (TPL::is_output('block/sidebar_hot_topics.tpl.htm', 'article/square')) { TPL::assign('sidebar_hot_topics', $this->model('module')->sidebar_hot_topics($category_info['id'])); } if ($category_info) { TPL::assign('category_info', $category_info); $this->crumb($category_info['title'], '/article/category-' . $category_info['id']); $meta_description = $category_info['title']; if ($category_info['description']) { $meta_description .= ' - ' . $category_info['description']; } TPL::set_meta('description', $meta_description); } TPL::assign('article_categories', $this->model('system')->fetch_category('article', 0)); TPL::assign('article_list', $article_list); TPL::assign('article_topics', $article_topics); // 推荐文章 TPL::assign('recommend_articles', $this->model('article')->get_recommend_article_list(null, 4)); // 热门文章 $hot_articles = $this->model('article')->get_articles_list(null, 1, 8, 'votes DESC', null); foreach ($hot_articles as $key => $val) { $article_ids[] = $val['id']; } $article_attachs = $this->model('publish')->get_attachs('article', $article_ids, 'min'); foreach ($hot_articles as $key => $val) { $hot_articles[$key]['attachs'] = $article_attachs[$val['id']]; } TPL::assign('hot_articles', $hot_articles); TPL::assign('pagination', AWS_APP::pagination()->initialize(array('base_url' => get_js_url('/article/category_id-' . $_GET['category_id'] . '__feature_id-' . $_GET['feature_id']), 'total_rows' => $article_list_total, 'per_page' => get_setting('contents_per_page')))->create_links()); TPL::output('article/square'); }
public function index_action() { if ($this->user_id) { $this->crumb(AWS_APP::lang()->_t('精选'), '/explore'); if (!$this->user_info['email']) { HTTP::redirect('/account/complete_profile/'); } } if ($_GET['category']) { if (is_digits($_GET['category'])) { $category_info = $this->model('system')->get_category_info($_GET['category']); } else { $category_info = $this->model('system')->get_category_info_by_url_token($_GET['category']); } } if ($category_info) { TPL::assign('category_info', $category_info); $this->crumb($category_info['title'], '/category-' . $category_info['id']); $meta_description = $category_info['title']; if ($category_info['description']) { $meta_description .= ' - ' . $category_info['description']; } TPL::set_meta('description', $meta_description); } // 首页幻灯片 $slides = $this->model('slide')->get_frontend_slides(); foreach ($slides as $key => $val) { $slides[$key]['category_info'] = $this->model('slide')->get_slide_category_info($val['category']); } TPL::assign('slides', $slides); // 导航 if (TPL::is_output('block/content_nav_menu.tpl.htm', 'explore/index')) { TPL::assign('content_nav_menu', $this->model('menu')->get_nav_menu_list('explore')); } // 置顶问题 $recommend_items = $this->model('recommend')->get_recommend_homepage_items('top_question', $limit = 4); foreach ($recommend_items as $key => $item) { $question_info = $this->model('question')->get_question_info_by_id($item['item_id']); if ($question_info['has_attach']) { $question_info['attachs'] = $this->model('publish')->get_attach('question', $question_info['question_id'], 'square'); } // 答题选项 if ($question_info['quiz_id'] > 0) { $question_info['quiz_info'] = $this->model('quiz')->get_question_quiz_info_by_id($question_info['quiz_id']); } // 分类信息 $question_info['category_info'] = $this->model('system')->get_category_info($question_info['category_id']); $top_question_list[$key] = $question_info; } TPL::assign('top_question_list', $top_question_list); // 精选问题 $filter_info = array('sort_type' => $_GET['sort_type'], 'category_id' => $category_info['id'], 'difficulty' => intval($_GET['difficulty']), 'quiztype' => intval($_GET['quiztype']), 'countdown' => intval($_GET['countdown']), 'urecord' => $_GET['urecord'], 'date' => $_GET['date'], 'url_base' => '/'); TPL::assign('filter_info', $filter_info); $recommend_question_list = $this->model('question')->get_homepage_recommend_question_list($_GET['page'], get_setting('contents_per_page'), $_GET['sort_type'], $category_info['id'], $_GET['difficulty'], $_GET['quiztype'], $_GET['countdown'], $_GET['urecord'], $_GET['date'], $this->user_id); if ($recommend_question_list) { foreach ($recommend_question_list as $key => $val) { $this->model('question')->load_list_question_info($recommend_question_list[$key], $val, $this->user_id); } } TPL::assign('recommend_homepage_questions', $recommend_question_list); // TPL::assign('pagination', AWS_APP::pagination()->initialize(array( // 'base_url' => get_js_url('/sort_type-' . preg_replace("/[\(\)\.;']/", '', $_GET['sort_type']) . '__category-' . $category_info['id'] . '__difficulty-' . $_GET['difficulty'] . '__quiztype-' . $_GET['quiztype'] . '__countdown-' . $_GET['countdown'] . '__is_recommend-' . $_GET['is_recommend'] . '__urecord-' . $_GET['urecord'] . '__date-' . $_GET['date']), // 'total_rows' => $this->model('question')->get_homepage_recommend_question_list_total(), // 'per_page' => get_setting('contents_per_page'), // 'num_links' => 2 // ))->create_links()); // 精选专题 $recommend_items = $this->model('recommend')->get_recommend_homepage_items('topic', $limit = 4); foreach ($recommend_items as $key => $item) { $topic_info = $this->model('topic')->get_topic_by_id($item['item_id']); $topic_info['topic_description'] = nl2br(FORMAT::parse_bbcode($topic_info['topic_description'])); if ($topic_info['parent_id']) { $parent_topic_info = $this->model('topic')->get_topic_by_id($topic_info['parent_id']); $topic_info['category'] = $parent_topic_info['topic_title']; $topic_info['category_id'] = $parent_topic_info['topic_id']; } $recommend_homepage_topics[$key] = $topic_info; } TPL::assign('recommend_homepage_topics', $recommend_homepage_topics); // 精选知识 $recommend_items = $this->model('recommend')->get_recommend_homepage_items('article', $limit = 5); foreach ($recommend_items as $key => $item) { $article_ids[] = $item['item_id']; } // 获取文章缩略图 $article_attachs = $this->model('publish')->get_attachs('article', $article_ids, 'min'); foreach ($recommend_items as $key => $item) { $article_info = $this->model('article')->get_article_info_by_id($item['item_id']); $article_info['attachs'] = $article_attachs[$article_info['id']]; $recommend_homepage_articles[$key] = $article_info; } TPL::assign('recommend_homepage_articles', $recommend_homepage_articles); // 边栏可能感兴趣的人 if (TPL::is_output('block/sidebar_recommend_users_topics.tpl.htm', 'explore/index')) { TPL::assign('sidebar_recommend_users_topics', $this->model('module')->recommend_users_topics($this->user_id)); } // 边栏热门用户 if (TPL::is_output('block/sidebar_hot_users.tpl.htm', 'explore/index')) { TPL::assign('sidebar_hot_users', $this->model('module')->sidebar_hot_users($this->user_id, 5)); } // 边栏热门话题 if (TPL::is_output('block/sidebar_hot_topics.tpl.htm', 'explore/index')) { TPL::assign('sidebar_hot_topics', $this->model('module')->sidebar_hot_topics($category_info['id'])); } // 边栏专题 if (TPL::is_output('block/sidebar_feature.tpl.htm', 'explore/index')) { TPL::assign('feature_list', $this->model('module')->feature_list()); } // if (! $_GET['sort_type'] AND !$_GET['is_recommend']) // { // $_GET['sort_type'] = 'new'; // } // if ($_GET['sort_type'] == 'hot') // { // $posts_list = $this->model('posts')->get_hot_posts(null, $category_info['id'], null, $_GET['day'], $_GET['page'], get_setting('contents_per_page')); // } // else // { // $posts_list = $this->model('posts')->get_posts_list(null, $_GET['page'], get_setting('contents_per_page'), $_GET['sort_type'], null, $category_info['id'], $_GET['answer_count'], $_GET['day'], $_GET['is_recommend']); // } // if ($posts_list) // { // foreach ($posts_list AS $key => $val) // { // if ($val['answer_count']) // { // $posts_list[$key]['answer_users'] = $this->model('question')->get_answer_users_by_question_id($val['question_id'], 2, $val['published_uid']); // } // } // } // TPL::assign('pagination', AWS_APP::pagination()->initialize(array( // 'base_url' => get_js_url('/sort_type-' . preg_replace("/[\(\)\.;']/", '', $_GET['sort_type']) . '__category-' . $category_info['id'] . '__day-' . intval($_GET['day']) . '__is_recommend-' . intval($_GET['is_recommend'])), // 'total_rows' => $this->model('posts')->get_posts_list_total(), // 'per_page' => get_setting('contents_per_page') // ))->create_links()); // TPL::assign('posts_list', $posts_list); // TPL::assign('posts_list_bit', TPL::output('explore/ajax/list', false)); // 是否签到成功 TPL::assign('signed_in', $this->model('sign')->is_signed_today($this->user_id)); // 用户排行榜 TPL::assign('top_user_list_success_ratio', array_values($this->model('account')->get_top_users('success_ratio', 3))); TPL::assign('top_user_list_integral', array_values($this->model('account')->get_top_users('integral', 3))); TPL::import_js('js/sweetalert.min.js'); TPL::import_css('css/sweetalert.css'); TPL::output('explore/index'); }