Index.class.php
2.17 KB
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
<?php
/**
* 首页控制器
*/
class Controller_Admin_Index extends Controller_Admin_Base
{
/**
* 首页列表Index
*/
public function indexAction()
{
$type = $this->_request->query('type', 1);
$info = Facade_Index::getIndex($type);
$this->_view['data'] = $info;
$this->_view['type'] = $type;
$this->_view['typeDescription'] = array( 1 =>'banner', 2 =>'广告', 3 =>'广告', 4=> '广告');
$this->_view['sizeDescription'] = array( 1 =>'980x474 [移动端:1180x500]', 2 =>'342x420', 3=>'1180x500px[移动端:320x155]', 4 =>'290x356px');
$this->_view['key'] = Lib_Images::genKey('fragmentimg');
}
/**
* 提交首页
*/
public function submitAction()
{
$id = $this->_request->query('id', 0);
$url = $this->_request->query('url','');
$text = $this->_request->query('text','');
$res = $this->_request->query('res','');
$sort = $this->_request->query('sort', 0);
$type = $this->_request->query('type', 1);
$width = $height = $times = 0;
while($width <= 0 && $height <= 0 && $times++<=5)
{
$info = Lib_Images::getImageInfo($res, 'fragmentimg');
$width = intval($info['width']);
$height = intval($info['height']);
}
$res_size = json_encode(array('width'=> $width, 'height'=> $height));
if($id)
{
$ret = Facade_Index::updateIndex($url, $text, $res, $type, $sort, $res_size, $id);
}
else
{
$ret = Facade_Index::submitIndex($url, $text, $res, $type, $sort, $res_size);
}
if($ret)
{
return $this->returnJson(true,200,null);
}
else
{
return $this->returnJson(false,404,null);
}
}
/**
* 删除首页信息
*/
public function delAction()
{
$id = $this->_request->query('id',0);
$ret = Facade_Index::delIndex($id);
if($ret)
{
return $this->returnJson(true,200,null);
}
else
{
return $this->returnJson(false,404,null);
}
}
}