|
|
<?php
|
|
|
|
|
|
use Action\AbstractAction;
|
|
|
use LibModels\Wap\Guang\ListData;
|
|
|
use Plugin\Helpers;
|
|
|
|
|
|
/**
|
|
|
* 逛首页、列表页、编辑页
|
|
|
*/
|
|
|
class IndexController extends AbstractAction
|
|
|
{
|
|
|
|
|
|
/**
|
|
|
* 首页
|
|
|
*
|
|
|
* @param int id 分类ID 0:最新,1:话题,2:搭配,3:潮人,4:潮品,5:小贴士
|
|
|
* @param string gender '1,3'表示男,'2,3'表示女, 默认为所有
|
|
|
*/
|
|
|
public function indexAction()
|
|
|
{
|
|
|
$this->setTitle('逛');
|
|
|
$this->setNavHeader('逛', true, SITE_MAIN);
|
|
|
|
|
|
$uid = $this->getUid();
|
|
|
$udid = $this->getUdid();
|
|
|
$type = $this->get('id', 0);
|
|
|
$gender = $this->get('gender');
|
|
|
|
|
|
$this->_view->display('index', Guang\IndexModel::getArticleGroup($gender, $type, $uid, $udid));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 列表页
|
|
|
*
|
|
|
* @param string tag 标签名称
|
|
|
* @param int yh_channel APP客户端标识 1表示男,2:表示女,3:潮童,4:创意生活
|
|
|
*/
|
|
|
public function tagAction()
|
|
|
{
|
|
|
$uid = $this->getUid();
|
|
|
$udid = $this->getUdid();
|
|
|
$tag = $this->get('query');
|
|
|
$channel = $this->get('yh_channel');
|
|
|
|
|
|
// 标签聚合内容列表
|
|
|
$article = ListData::article('', 0, $uid, $udid, 1, $tag);
|
|
|
// 标签聚合内容不存在, 跳到错误页面
|
|
|
if (empty($article['data']['list']['artList'])) {
|
|
|
$this->error();
|
|
|
}
|
|
|
// 标识是不是APP客户端
|
|
|
$isApp = isset($channel);
|
|
|
|
|
|
$this->setTitle($tag);
|
|
|
if (!$isApp) {
|
|
|
$this->setNavHeader($tag, true, SITE_MAIN);
|
|
|
}
|
|
|
|
|
|
$data = array();
|
|
|
// 模板中使用JS的标识
|
|
|
$data['guangList'] = true;
|
|
|
|
|
|
// 构建资讯文章内容
|
|
|
$build = array();
|
|
|
foreach ($article['data']['list']['artList'] as $article) {
|
|
|
$build[] = Helpers::formatArticle($article, true, $isApp);
|
|
|
}
|
|
|
$data['guang']['infos'] = $build;
|
|
|
|
|
|
// 分页需要的参数
|
|
|
$data['guang']['tag'] = $tag;
|
|
|
|
|
|
$this->_view->display('list', $data);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 编辑页
|
|
|
*
|
|
|
* @param int id 作者ID
|
|
|
* @param int yh_channel APP客户端标识 1表示男,2:表示女,3:潮童,4:创意生活
|
|
|
*/
|
|
|
public function editorAction()
|
|
|
{
|
|
|
$id = $this->get('id');
|
|
|
$channel = $this->get('yh_channel');
|
|
|
|
|
|
// 获取作者信息
|
|
|
$author = ListData::author($id);
|
|
|
// 作者信息不存在,则跳到错误页面
|
|
|
if (!isset($author['name'])) {
|
|
|
$this->error();
|
|
|
}
|
|
|
// 标识是不是APP客户端
|
|
|
$isApp = isset($channel);
|
|
|
|
|
|
$this->setTitle('编辑简介');
|
|
|
if (!$isApp) {
|
|
|
$this->setNavHeader('编辑简介', true, SITE_MAIN);
|
|
|
}
|
|
|
|
|
|
$uid = $this->getUid();
|
|
|
$udid = $this->getUdid();
|
|
|
|
|
|
$data = array();
|
|
|
// 模板中使用JS的标识
|
|
|
$data['guangList'] = true;
|
|
|
|
|
|
// 作者信息
|
|
|
$data['author'] = array();
|
|
|
$data['author']['avatar'] = Helpers::getImageUrl($author['avatar'], 100, 100);
|
|
|
$data['author']['name'] = $author['name'];
|
|
|
$data['author']['info'] = $author['author_desc'];
|
|
|
$data['author']['id'] = $id;
|
|
|
|
|
|
// 标签聚合内容列表
|
|
|
$article = ListData::article('', 0, $uid, $udid, 1, null, $id);
|
|
|
// 构建资讯文章内容
|
|
|
if (!empty($article['data']['list']['artList'])) {
|
|
|
$build = array();
|
|
|
foreach ($article['data']['list']['artList'] as $article) {
|
|
|
$build[] = Helpers::formatArticle($article, true, false, false);
|
|
|
}
|
|
|
$data['guang']['infos'] = $build;
|
|
|
}
|
|
|
|
|
|
$this->_view->display('list', $data);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 逛列表页面的资讯分页
|
|
|
*
|
|
|
* 逛首页、标签页、编辑页资讯列表
|
|
|
*
|
|
|
* @param string tag 标签名称, 没有传空或不传
|
|
|
* @param int type 逛首页的分类ID
|
|
|
* @param int page 分页的页码
|
|
|
* @param string gender "1,2,3"表示所有, "1,3"表示男, "2,3"表示女
|
|
|
* @param int authorId 作者ID
|
|
|
* @return html
|
|
|
*/
|
|
|
public function pageAction()
|
|
|
{
|
|
|
do {
|
|
|
/* 判断是不是AJAX请求 */
|
|
|
if (!$this->isAjax()) {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
/* 判断参数是否有效 */
|
|
|
$tag = $this->get('tag');
|
|
|
$sortId = $this->get('type', 0);
|
|
|
$page = $this->get('page');
|
|
|
$gender = $this->get('gender');
|
|
|
$authorId = $this->get('authorId');
|
|
|
$showAuthor = true;
|
|
|
if (!empty($sortId) && !is_numeric($sortId)) {
|
|
|
break;
|
|
|
}
|
|
|
if (!empty($page) && !is_numeric($page)) {
|
|
|
break;
|
|
|
}
|
|
|
if (!empty($authorId) && is_numeric($authorId)) {
|
|
|
$showAuthor = false;
|
|
|
}
|
|
|
|
|
|
/* 获取资讯文章列表 */
|
|
|
$uid = $this->getUid();
|
|
|
$udid = $this->getUdid();
|
|
|
$page = intval($page) + 1;
|
|
|
$article = ListData::article($gender, $sortId, $uid, $udid, $page, $tag, $authorId);
|
|
|
if (empty($article['data']['list']['artList'])) {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
/* 构建资讯文章内容 */
|
|
|
$data = array();
|
|
|
$build = array();
|
|
|
foreach ($article['data']['list']['artList'] as $article) {
|
|
|
$build[] = Helpers::formatArticle($article, true, false, $showAuthor);
|
|
|
}
|
|
|
$data['infos'] = $build;
|
|
|
|
|
|
$this->_view->display('page', $data);
|
|
|
|
|
|
exit();
|
|
|
|
|
|
} while (false);
|
|
|
|
|
|
echo ' ';
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|