1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- <?php
- namespace Content\Lib;
- use Dever;
- class News
- {
-
- public function getHome($type = 1, $limit = 3, $page = 'article')
- {
- $where = array();
- if ($type) {
- $where['type'] = $type;
- }
- $where['limit'] = '0,' . $limit;
- $data = Dever::db('content/news')->getHome($where);
- if ($data) {
- foreach ($data as $k => $v) {
- $data[$k] = $this->getOne($v);
- }
- }
- return $data;
- }
-
- public function getAll($type = 1, $name = '')
- {
- $where = array();
- if ($type && $type > 0) {
- $where['type'] = $type;
- }
- if($name) {
- $where['name'] = $name;
- $where['tag'] = $name;
- }
- $data = Dever::db('content/news')->getAll($where);
- if ($data) {
- foreach ($data as $k => $v) {
- $data[$k] = $this->getOne($v);
- }
- }
- return $data;
- }
- public function getInfo($type, $id)
- {
- $where = array();
- if ($type) {
- $where['type'] = $type;
- }
- $where['id'] = $id;
- $data = Dever::db('content/news')->getOne($where);
- if ($data) {
- $data = $this->getOne($data);
- }
- return $data;
- }
- private function getOne($info)
- {
- $info['link'] = Dever::url('main/article?type='.$info['type'].'&id=' . $info['id']);
- $info['pdate_string'] = date('M d, Y', $info['pdate']);
- if ($info['author']) {
- $info['pdate_string'] .= ' by ' . $info['author'];
- }
- $info['pdate_s'] = date('Y/m/d', $info['pdate']);
- $info['video_link'] = Dever::url('main/content.video?id=' . $info['id']);
-
- $info['sname'] = $info['name'] . '<br />' . $info['desc'];
- return $info;
- }
- }
|