public function detail(Request $request, Response $response) { if ($request->is_hashreq()) { $aid = $request->arg(2); $info = Activity_Model::getActivityByAid($aid); //模板 if ($info['tpl'] == 0) { $this->v->set_tplname('mod_activity_detail'); $this->v->assign('nav_no', 4); } elseif ($info['tpl'] == 1) { $this->v->set_tplname('mod_activity_1'); $this->v->assign('nav_no', 0); } $is_voted = 0; $user = Member::getUser(); if (Member::isLogined()) { $is_voted = Activity_Model::isJoin($aid, $user['uid'], 'vote'); } $this->v->assign('info', $info); $this->v->assign('is_voted', $is_voted); //关联信息 $relation = ''; $type_id = 'music'; $music = Activity_Model::getRelated($aid, $type_id); import('Node/Node_Model'); foreach ($music as &$val) { $val['love'] = Node_Model::actionRecord($val['nid'], $user['uid'], 'love'); } $cur_dir = dirname(__FILE__); $music_tpl = $cur_dir . '/tpl/mod_activity_detail_music.tpl.htm'; if ($music) { ob_start(); include $music_tpl; $relation = ob_get_contents(); ob_end_clean(); } $this->v->assign('relation', $relation); } $response->send($this->v); }
public function updateSearch(Request $request, Response $response) { $nodes = D()->query('SELECT * FROM {node} ')->fetch_array_all(); $typeData = Node_Model::getTypeList(); $typeList = []; foreach ($typeData as $val) { $typeList[$val['type_id']] = $val['type_name']; } foreach ($nodes as $params) { $search = $typeList[$params['type_id']]; $search .= ',' . $params['keyword'] . ',' . $params['tag']; D()->update('node', ['search' => $search], ['nid' => $params['nid']]); } header('Content-type:text/html;charset=utf-8'); exit('更新搜索字段完成'); }
public function related(Request $request, Response $response) { $aid = $request->arg(2); if (empty($aid)) { exit('缺少参数'); } import('Node/Node_Model'); $typelist = Node_Model::getTypeList(); $types = []; foreach ($typelist as $v) { $types[$v['type_id']] = $v['type_name']; } $type_id = ''; //类别筛选 $viewRelated = ''; //只显示已关联 if (!empty($_POST)) { $type_id = $request->post('type_id', ''); //类别筛选 $viewRelated = $request->post('viewRelated', ''); //只显示已关联 $_query['type_id'] = $type_id; $_query['viewRelated'] = $viewRelated; $_SESSION['_query']['activity_related'] = $_query; } elseif (isset($_SESSION['_query']['activity_related'])) { $_query = $_SESSION['_query']['activity_related']; $type_id = $_query['type_id']; //类别筛选 $viewRelated = $_query['viewRelated']; //只显示已关联 } $page_size = 20; $where = []; $where['aid'] = $aid; if ($type_id != '') { $where['type_id'] = $type_id; } if ($viewRelated != '') { $where['viewRelated'] = $viewRelated; } $list = Activity_Model::getRelatedList($page_size, $where); $totalNum = $GLOBALS['pager_totalrecord_arr'][0]; $recordNum = $GLOBALS['pager_totalpage_arr'][0]; $qparturl = '#/activity/related/' . $aid; $extraurl = ''; $this->v->assign('types', $types); $this->v->assign('typelist', $typelist)->assign('type_id', $type_id)->assign('viewRelated', $viewRelated); $this->v->assign('list', $list)->assign('aid', $aid); $this->v->assign('totalNum', $totalNum)->assign('recordNum', $recordNum); $this->v->assign('qparturl', $qparturl)->assign('extraurl', $extraurl); $this->v->set_tplname('mod_activity_related'); $response->send($this->v); }