-
Notifications
You must be signed in to change notification settings - Fork 0
/
article_list.php
90 lines (68 loc) · 2.79 KB
/
article_list.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
/**
* Created by PhpStorm.
* User: apple
* Date: 15/10/10
* Time: 上午10:06
*/
include 'library/init.inc.php';
$operation = 'sort';
$opera = check_action($operation, getPOST('opera'));
if('sort' == $opera)
{
$response = array('error' => 1, 'msg' => '');
$mode = getPOST('mode');
if($mode != 'all')
{
$mode = intval($mode);
}
$get_article_list = 'select `title`,`id`,`add_time`,`description`,`original` from '.$db->table('content').' where `status`<>0 ';
switch($mode)
{
case 'all':
$get_article_list .= ' and `section_id` in (1,2,3)';
break;
default:
$get_article_list .= ' and `section_id`='.$mode;
break;
}
$get_article_list .= ' order by `order_view` ASC,`add_time` DESC';
$article_list = $db->fetchAll($get_article_list);
assign('article_list', $article_list);
assign('section_list', null);
$response['error'] = 0;
$response['content'] = $smarty->fetch('news-list-item.phtml');
echo json_encode($response);
exit;
}
$id = getGET('id');
$id = intval($id);
$get_functions = 'select `name`,`url` from '.$db->table('modules').' where `assoc_type`=\'section_id\' and `assoc`='.$id;
$functions = $db->fetchAll($get_functions);
$get_section_list = 'select `section_name`, `id`,`original` from '.$db->table('section').' where `parent_id` = '.$id.' order by `order_view` asc';
$section_list = $db->fetchAll($get_section_list);
if(empty($section_list) && empty($functions) && $id <= 5) {
$get_section_list = 'select `section_name`, `id`,`original` from '.$db->table('section').' where `parent_id` = 0 and `id`<=5 order by `order_view` asc';
$section_list = $db->fetchAll($get_section_list);
}
if( $section_list && empty($functions)) {
$get_article_list = 'select `title`,`id`,`add_time`,`description`,`original` from ' . $db->table('content') . ' where `section_id`='.$id.' and `status`<>0 order by `order_view` ASC,`add_time` DESC';
$article_list = $db->fetchAll($get_article_list);
assign('width', (100 / count($section_list)));
} else {
$get_article_list = 'select `title`,`id`,`add_time`,`description`,`original` from ' . $db->table('content') . ' where `section_id`='.$id.' and `status`<>0 order by `order_view` ASC,`add_time` DESC';
$article_list = $db->fetchAll($get_article_list);
$tag_width = 25;
if($functions) {
$tag_width = (100 / count($functions));
}
assign('width', $tag_width);
}
assign('functions', $functions);
assign('article_list', $article_list);
assign('all', $id);
assign('section_list', $section_list);
$get_section = 'select `section_name` from '.$db->table('section').' where `id`='.$id;
$section = $db->fetchRow($get_section);
assign('title', $section['section_name']);
$smarty->display('news-list.phtml');