Index.class.php
2.36 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
/**
* 首页
*
* @name Service_Index
* @version 1.0 (2013-6-5)
* @package Service/News
* @since 1.0
*/
class Service_Index extends Lib_Service
{
const ROUTER = 'index.yohood.index';
private static $_tag = 'tag_yohood_index_';
private static $_key = 'key_yohood_index_';
/**
* 获取首页信息
*
* @param string $type
* @return array
*/
public function getIndex ($type)
{
return self::service(self::ROUTER)->tag(self::$_tag)->fetchAssoc('getBannerByType', array('type' => $type));
}
/**
* 根据id更新首页信息状态.
* 用于管理员更新一个首页信息的操作.
*
* @param string $url
* @param string $text
* @param string $res
* @param int $type
* @param int $sort
* @param string $res_size
* @param int $id
* @return boolean
*/
public function updateIndex ($url, $text, $res, $type, $sort, $res_size, $id)
{
$param = array('id' => $id, 'text' => $text, 'res' => $res,'url'=> $url,'type'=> $type, 'sort' => $sort, 'res_size'=> $res_size);
$status = self::service(self::ROUTER)->cache(false)->update('updateBanner', $param)->status();
if($status)
{
self::service(self::ROUTER)->delTags(self::$_tag);
}
return $status;
}
/**
* 用户提交首页信息
*
* @param string $url
* @param string $text
* @param string $res
* @param int $type
* @param int $sort
* @param string $res_size
* @return boolean
*/
public function submitIndex ($url, $text, $res, $type, $sort, $res_size)
{
$param = array('url' => $url, 'res' => $res, 'text'=> $text, 'type'=> $type,'sort' => $sort,'res_size'=> $res_size);
$status = self::service(self::ROUTER)->cache(false)->insert('insertBanner', $param)->lastInsertId();
if($status)
{
self::service(self::ROUTER)->delTags(self::$_tag);
}
return $status;
}
/**
* 删除首页信息
*
* @param int $id
* @return boolean
*/
public function delIndex($id)
{
$status = self::service(self::ROUTER)->cache(false)->delete('delIndex',array('id'=>$id))->status();
if($status)
{
self::service(self::ROUTER)->delTags(self::$_tag);
}
return $status;
}
}