1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192 |
- <?php
-
- namespace app\admin\controller;
-
- use think\Page;
- use think\Db;
-
- class Custom extends Base
- {
-
- public $nid = '';
-
- public $channeltype = 0;
-
- public $table = '';
-
-
-
- public function _initialize()
- {
- parent::_initialize();
- $this->archives_db = Db::name('archives');
-
- $this->channeltype = input('param.channel/d', 0);
- $channeltypeRow = Db::name('channeltype')->field('nid,table')->where(['id'=>['eq',$this->channeltype]])->find();
- if (empty($this->channeltype) || empty($channeltypeRow)) {
- $this->error('自定义模型ID丢失,打开失败!');
- }
-
- $this->nid = $channeltypeRow['nid'];
- $this->table = $channeltypeRow['table'];
-
- $this->assign('nid', $this->nid);
- $this->assign('table', $this->table);
- $this->assign('channeltype', $this->channeltype);
-
-
- $paramTypeid = input('param.typeid/d', 0);
- $this->callback_url = url('Custom/index', ['lang' => $this->admin_lang, 'channel'=>$this->channeltype, 'typeid' => $paramTypeid]);
- $this->assign('callback_url', $this->callback_url);
- }
-
-
- public function index()
- {
- $assign_data = $condition = [];
-
-
- $param = input('param.');
- $typeid = input('typeid/d', 0);
-
-
- foreach (['keywords', 'typeid', 'flag', 'is_release','province_id','city_id','area_id'] as $key) {
- if ($key == 'typeid' && empty($param['typeid'])) {
- $typeids = Db::name('arctype')->where('current_channel', $this->channeltype)->column('id');
- $condition['a.typeid'] = array('IN', $typeids);
- }
- if (isset($param[$key]) && $param[$key] !== '') {
- if ($key == 'keywords') {
- $keywords = $param[$key];
- $condition['a.title'] = array('LIKE', "%{$param[$key]}%");
- } else if ($key == 'typeid') {
- $typeid = $param[$key];
- $hasRow = model('Arctype')->getHasChildren($typeid);
- $typeids = get_arr_column($hasRow, 'id');
-
- $admin_info = session('admin_info');
- if (0 < intval($admin_info['role_id'])) {
- $auth_role_info = $admin_info['auth_role_info'];
- if (!empty($typeid) && !empty($auth_role_info) && !empty($auth_role_info['permission']['arctype'])) {
- $typeids = array_intersect($typeids, $auth_role_info['permission']['arctype']);
- }
- }
- $condition['a.typeid'] = array('IN', $typeids);
- } else if ($key == 'flag') {
- if ('is_release' == $param[$key]) {
- $condition['a.users_id'] = array('gt', 0);
- } else {
- $FlagNew = $param[$key];
- $condition['a.'.$param[$key]] = array('eq', 1);
- }
- } else if (in_array($key, ['province_id','city_id','area_id'])) {
- if (!empty($param['area_id'])) {
- $condition['a.area_id'] = $param['area_id'];
- } else if (!empty($param['city_id'])) {
- $condition['a.city_id'] = $param['city_id'];
- } else if (!empty($param['province_id'])) {
- $condition['a.province_id'] = $param['province_id'];
- }
- } else {
- $condition['a.'.$key] = array('eq', $param[$key]);
- }
- }
- }
-
-
- $admin_info = session('admin_info');
- if (0 < intval($admin_info['role_id'])) {
- $auth_role_info = $admin_info['auth_role_info'];
- if (!empty($auth_role_info) && isset($auth_role_info['only_oneself']) && 1 == $auth_role_info['only_oneself']) {
- $condition['a.admin_id'] = $admin_info['admin_id'];
- }
- }
-
-
- $begin = strtotime(input('add_time_begin'));
- $end = strtotime(input('add_time_end'));
- if ($begin > 0 && $end > 0) {
- $condition['a.add_time'] = array('between', "$begin, $end");
- } else if ($begin > 0) {
- $condition['a.add_time'] = array('egt', $begin);
- } else if ($end > 0) {
- $condition['a.add_time'] = array('elt', $end);
- }
-
-
- $condition['a.channel'] = array('eq', $this->channeltype);
- $condition['a.lang'] = array('eq', $this->admin_lang);
- $condition['a.is_del'] = array('eq', 0);
- $conditionNew = "(a.users_id = 0 OR (a.users_id > 0 AND a.arcrank >= 0))";
-
-
- $orderby = input('param.orderby/s');
- $orderway = input('param.orderway/s');
- if (!empty($orderby) && !empty($orderway)) {
- $orderby = "a.{$orderby} {$orderway}, a.aid desc";
- } else {
- $orderby = "a.aid desc";
- }
-
-
- $SqlQuery = $this->archives_db->alias('a')->where($condition)->where($conditionNew)->fetchSql()->count('aid');
- $count = Db::name('sql_cache_table')->where(['sql_md5'=>md5($SqlQuery)])->getField('sql_result');
- $count = ($count < 0) ? 0 : $count;
- if (empty($count)) {
- $count = $this->archives_db->alias('a')->where($condition)->where($conditionNew)->count('aid');
-
- $SqlCacheTable = [
- 'sql_name' => '|' . $this->table . '|' . $this->channeltype . '|',
- 'sql_result' => $count,
- 'sql_md5' => md5($SqlQuery),
- 'sql_query' => $SqlQuery,
- 'add_time' => getTime(),
- 'update_time' => getTime(),
- ];
- if (!empty($FlagNew)) $SqlCacheTable['sql_name'] = $SqlCacheTable['sql_name'] . $FlagNew . '|';
- if (!empty($typeid)) $SqlCacheTable['sql_name'] = $SqlCacheTable['sql_name'] . $typeid . '|';
- if (!empty($keywords)) $SqlCacheTable['sql_name'] = '|custom|keywords|';
- Db::name('sql_cache_table')->insertGetId($SqlCacheTable);
-
- }
-
- $Page = new Page($count, config('paginate.list_rows'));
- $list = [];
- if (!empty($count)) {
- $limit = $count > config('paginate.list_rows') ? $Page->firstRow.','.$Page->listRows : $count;
- $list = $this->archives_db
- ->field("a.aid")
- ->alias('a')
- ->where($condition)
- ->where($conditionNew)
- ->order($orderby)
- ->limit($limit)
- ->getAllWithIndex('aid');
- if (!empty($list)) {
- $aids = array_keys($list);
- $fields = "b.*, a.*, a.aid as aid";
- $row = $this->archives_db
- ->field($fields)
- ->alias('a')
- ->join('__ARCTYPE__ b', 'a.typeid = b.id', 'LEFT')
- ->where('a.aid', 'in', $aids)
- ->getAllWithIndex('aid');
- foreach ($list as $key => $val) {
- $row[$val['aid']]['arcurl'] = get_arcurl($row[$val['aid']]);
- $row[$val['aid']]['litpic'] = handle_subdir_pic($row[$val['aid']]['litpic']);
- $list[$key] = $row[$val['aid']];
- }
- }
- }
-
- $show = $Page->show();
- $assign_data['page'] = $show;
- $assign_data['list'] = $list;
- $assign_data['pager'] = $Page;
- $assign_data['typeid'] = $typeid;
- $assign_data['tab'] = input('param.tab/d', 3);
- $assign_data['archives_flags'] = model('ArchivesFlag')->getList();
- $assign_data['arctype_info'] = $typeid > 0 ? Db::name('arctype')->field('typename')->find($typeid) : [];
- $this->assign($assign_data);
- return $this->fetch();
- }
-
-
-
- public function add()
- {
- $admin_info = session('admin_info');
- $auth_role_info = $admin_info['auth_role_info'];
- $this->assign('auth_role_info', $auth_role_info);
- $this->assign('admin_info', $admin_info);
-
- if (IS_POST) {
- $post = input('post.');
- model('Archives')->editor_auto_210607($post);
-
- if (!empty($post['tags_new'])) {
- $post['tags'] = !empty($post['tags']) ? $post['tags'] . ',' . $post['tags_new'] : $post['tags_new'];
- unset($post['tags_new']);
- }
- $post['tags'] = explode(',', $post['tags']);
- $post['tags'] = array_unique($post['tags']);
- $post['tags'] = implode(',', $post['tags']);
-
-
-
- $contentField = Db::name('channelfield')->where([
- 'channel_id' => $this->channeltype,
- 'dtype' => 'htmltext',
- ])->getField('name');
- $content = empty($post['addonFieldExt'][$contentField]) ? '' : htmlspecialchars_decode($post['addonFieldExt'][$contentField]);
-
-
-
- $seo_keywords = $post['seo_keywords'];
- if (!empty($seo_keywords)) {
- $seo_keywords = str_replace(',', ',', $seo_keywords);
- } else {
-
- }
-
-
- $is_remote = !empty($post['is_remote']) ? $post['is_remote'] : 0;
- $litpic = '';
- if ($is_remote == 1) {
- $litpic = $post['litpic_remote'];
- } else {
- $litpic = $post['litpic_local'];
- }
- if (empty($litpic)) {
- $litpic = get_html_first_imgurl($content);
- }
- $post['litpic'] = $litpic;
-
-
- if (empty($post['litpic'])) {
- $is_litpic = 0;
- } else {
- $is_litpic = 1;
- }
-
-
- $seo_description = '';
- if (empty($post['seo_description']) && !empty($content)) {
- $seo_description = @msubstr(checkStrHtml($content), 0, config('global.arc_seo_description_length'), false);
- } else {
- $seo_description = $post['seo_description'];
- }
-
-
- $jumplinks = '';
- $is_jump = isset($post['is_jump']) ? $post['is_jump'] : 0;
- if (intval($is_jump) > 0) {
- $jumplinks = $post['jumplinks'];
- }
-
-
- if ($post['type_tempview'] == $post['tempview']) {
- unset($post['type_tempview']);
- unset($post['tempview']);
- }
-
-
- $htmlfilename = trim($post['htmlfilename']);
- if (!empty($htmlfilename)) {
- $htmlfilename = preg_replace("/[^\x{4e00}-\x{9fa5}\w\-]+/u", "-", $htmlfilename);
-
-
- $map = [
- 'htmlfilename' => $htmlfilename,
- 'lang' => $this->admin_lang,
- ];
- if (!empty($post['typeid'])) {
- $map['typeid'] = array('eq', $post['typeid']);
- }
- $filenameCount = Db::name('archives')->where($map)->count();
- if (!empty($filenameCount)) {
- $this->error("同栏目下,自定义文件名已存在!");
- } else if (preg_match('/^(\d+)$/i', $htmlfilename)) {
- $this->error("自定义文件名不能纯数字,会与文档ID冲突!");
- }
- } else {
-
- if (is_dir('./weapp/Waimao/')) {
- $waimaoLogic = new \weapp\Waimao\logic\WaimaoLogic;
- $waimaoLogic->get_new_htmlfilename($htmlfilename, $post, 'add', $this->globalConfig);
- }
- }
- $post['htmlfilename'] = $htmlfilename;
-
-
- if ($admin_info['role_id'] > 0 && $auth_role_info['check_oneself'] < 1) {
- $post['arcrank'] = -1;
- }
-
-
- if (isset($post['stypeid'])) {
- $post['stypeid'] = preg_replace('/([^\d\,\,]+)/i', ',', $post['stypeid']);
- $post['stypeid'] = str_replace(',', ',', $post['stypeid']);
- $post['stypeid'] = trim($post['stypeid'], ',');
- $post['stypeid'] = str_replace(",{$post['typeid']},", ',', ",{$post['stypeid']},");
- $post['stypeid'] = trim($post['stypeid'], ',');
- }
-
-
- $sort_order = Db::name('archives')->where('aid','=',(int)$post['level_group_name'])->value('sort_order');
-
-
- if(!empty($post['addonFieldExt']['down_eyou_remote'])){
- $file = explode('.',$post['addonFieldExt']['down_eyou_remote']);
- $ext = end($file);
- }else{
- $ext = '';
- }
-
-
- $newData = array(
- 'typeid'=> empty($post['typeid']) ? 0 : $post['typeid'],
- 'channel' => $this->channeltype,
- 'is_b' => empty($post['is_b']) ? 0 : $post['is_b'],
- 'is_head' => empty($post['is_head']) ? 0 : $post['is_head'],
- 'is_special' => empty($post['is_special']) ? 0 : $post['is_special'],
- 'is_recom' => empty($post['is_recom']) ? 0 : $post['is_recom'],
- 'is_roll' => empty($post['is_roll']) ? 0 : $post['is_roll'],
- 'is_slide' => empty($post['is_slide']) ? 0 : $post['is_slide'],
- 'is_diyattr' => empty($post['is_diyattr']) ? 0 : $post['is_diyattr'],
- 'editor_remote_img_local'=> empty($post['editor_remote_img_local']) ? 0 : $post['editor_remote_img_local'],
- 'editor_img_clear_link' => empty($post['editor_img_clear_link']) ? 0 : $post['editor_img_clear_link'],
- 'is_jump' => $is_jump,
- 'is_litpic' => $is_litpic,
- 'jumplinks' => $jumplinks,
- 'origin' => empty($post['origin']) ? '网络' : $post['origin'],
- 'seo_keywords' => $seo_keywords,
- 'seo_description' => $seo_description,
- 'admin_id' => session('admin_info.admin_id'),
- 'lang' => $this->admin_lang,
- 'sort_order' => 100,
- 'crossed_price' => empty($post['crossed_price']) ? 0 : floatval($post['crossed_price']),
- 'add_time' => strtotime($post['add_time']),
- 'update_time' => strtotime($post['add_time']),
- 'product_id' => (int)$post['product_id'],
- 'lunwen_id' => (int)$post['lunwen_id'],
- 'level_group_id' => (int)$post['level_group_id'],
- 'level_id' => (int)$post['level_group_name'],
- 'level' => (int)$sort_order,
- 'product_tag_id' => (int)$post['product_tag_id'],
- 'area_tag_id' => (int)$post['area_tag_id'],
- 'ext' => $ext
- );
- $data = array_merge($post, $newData);
-
- $aid = $this->archives_db->insertGetId($data);
- $_POST['aid'] = $aid;
- if ($aid) {
-
- model('Custom')->afterSave($aid, $data, 'add', $this->table);
-
- model('SqlCacheTable')->InsertSqlCacheTable();
-
- adminLog('新增数据:'.$data['title']);
-
-
-
- if((int)$newData['typeid'] === 116 || (int)$newData['typeid'] === 123 || (int)$newData['typeid'] === 127 || (int)$newData['typeid'] === 128){
- $last = Db::name('seo_number')->where([
- "type" => 4,
- "tid" => (int)$post['typeid'],
- 'topid' => 0,
- 'parentid' => 0,
- 'area_id' => 0,
- ])->order('number desc')->find();
- if(empty($last['number'])){
- $num = 1;
- }else{
- $num = (int)$last['number'] + 1;
- }
- $in_data = [
- "type" => 4,
- "aid" => $aid,
- "tid" => (int)$post['typeid'],
- 'is_del' => 0,
- 'is_kan' => 0,
- 'status' => 1,
- 'area_id' => 0,
- 'topid' => 0,
- 'parentid' => 0,
- 'number' => $num
- ];
- Db::name('seo_number')->insert($in_data);
- }else if((int)$newData['typeid'] === 126 || (int)$newData['typeid'] === 825 || (int)$newData['typeid'] === 826){
-
- $last = Db::name('seo_number')->where([
- "type" => 5,
- "tid" => (int)$post['typeid'],
- 'topid' => 0,
- 'parentid' => 0,
- 'area_id' => (int)$post['province_id'],
- ])->order('number desc')->find();
- if(empty($last['number'])){
- $num = 1;
- }else{
- $num = (int)$last['number'] + 1;
- }
- $in_data = [
- "type" => 5,
- "aid" => $aid,
- "tid" => (int)$post['typeid'],
- 'is_del' => 0,
- 'is_kan' => 0,
- 'status' => 1,
- 'area_id' => (int)$post['province_id'],
- 'topid' => 0,
- 'parentid' => 0,
- 'number' => $num
- ];
- Db::name('seo_number')->insert($in_data);
-
- }else if((int)$newData['typeid'] === 120 || (int)$newData['typeid'] === 118 || (int)$newData['typeid'] === 122 || (int)$newData['typeid'] === 11100000 || (int)$newData['typeid'] === 133 || (int)$newData['typeid'] === 132 || (int)$newData['typeid'] === 131 || (int)$newData['typeid'] === 306){
-
- $last = Db::name('seo_number')->where([
- "type" => 2,
- "tid" => (int)$post['typeid'],
- 'topid' => 0,
- 'parentid' => 0,
- 'area_id' => 0,
- ])->order('number desc')->find();
-
- if(empty($last['number'])){
- $num = 1;
- }else{
- $num = (int)$last['number'] + 1;
- }
- $in_data = [
- "type" => 2,
- "aid" => $aid,
- "tid" => (int)$post['typeid'],
- 'is_del' => 0,
- 'is_kan' => 0,
- 'status' => 1,
- 'area_id' => 0,
- 'topid' => 0,
- 'parentid' => 0,
- 'number' => $num
- ];
- Db::name('seo_number')->insert($in_data);
- }else if((int)$newData['typeid'] === 115 || (int)$newData['typeid'] === 117 || (int)$newData['typeid'] === 111){
-
-
- $where6 = [
- "type" => 2,
- "tid" => (int)$post['typeid'],
- 'topid' => 0,
- 'parentid' => 0,
- 'area_id' => (int)$post['province_id'],
- 'city_id' => (int)$post['city_id'],
- ];
-
-
-
-
- $last = Db::name('seo_number')->where($where6)->order('number desc')->find();
-
- if(empty($last['number'])){
- $num = 1;
- }else{
- $num = (int)$last['number'] + 1;
- }
- $in_data = [
- "type" => 2,
- "aid" => $aid,
- "tid" => (int)$post['typeid'],
- 'is_del' => 0,
- 'is_kan' => 0,
- 'status' => 1,
- 'area_id' => (int)$post['province_id'],
- 'city_id' => (int)$post['city_id'],
- 'topid' => 0,
- 'parentid' => 0,
- 'number' => $num
- ];
- Db::name('seo_number')->insert($in_data);
-
- }else if((int)$newData['typeid'] === 1231 || (int)$newData['typeid'] === 1233 || (int)$newData['typeid'] === 1234){
-
-
- $where6 = [
- "type" => 2,
- "tid" => (int)$post['typeid'],
- 'topid' => 0,
- 'parentid' => 0,
- 'area_id' => 0,
- 'city_id' => 0,
- ];
-
-
-
-
- $last = Db::name('seo_number')->where($where6)->order('number desc')->find();
-
- if(empty($last['number'])){
- $num = 1;
- }else{
- $num = (int)$last['number'] + 1;
- }
- $in_data = [
- "type" => 2,
- "aid" => $aid,
- "tid" => (int)$post['typeid'],
- 'is_del' => 0,
- 'is_kan' => 0,
- 'status' => 1,
- 'area_id' => 0,
- 'city_id' => 0,
- 'topid' => 0,
- 'parentid' => 0,
- 'number' => $num
- ];
- Db::name('seo_number')->insert($in_data);
-
- }else if((int)$newData['typeid'] === 1232){
-
-
-
- $where6 = [
- "type" => 2,
- "tid" => (int)$post['typeid'],
- 'topid' => 0,
- 'parentid' => 0,
- 'area_id' => (int)$post['area_tag_id'],
- 'city_id' => 0,
- ];
-
-
-
-
- $last = Db::name('seo_number')->where($where6)->order('number desc')->find();
-
- if(empty($last['number'])){
- $num = 1;
- }else{
- $num = (int)$last['number'] + 1;
- }
- $in_data = [
- "type" => 2,
- "aid" => $aid,
- "tid" => (int)$post['typeid'],
- 'is_del' => 0,
- 'is_kan' => 0,
- 'status' => 1,
- 'area_id' => (int)$post['area_tag_id'],
- 'city_id' => 0,
- 'topid' => 0,
- 'parentid' => 0,
- 'number' => $num
- ];
- Db::name('seo_number')->insert($in_data);
-
- }else{
-
- }
-
-
- $successData = [
- 'aid' => $aid,
- 'tid' => $post['typeid'],
- ];
- $this->success("操作成功!", null, $successData);
- }
- $this->error("操作失败!");
- }
-
-
-
-
- $typeid = input('param.typeid/d', 0);
- $assign_data['typeid'] = $typeid;
-
-
- $list = Db::name('arctype_cat')
- ->where('parent_id','=',$typeid)
- ->where('type','=','产品')
- ->where('is_del','=',0)
- ->order('id asc')
- ->select();
-
-
- $this->assign('pro_list',$list);
-
-
- $level_group_list = Db::name('arctype')
- ->field('id,parent_id,typename')
- ->where('parent_id','=',53)
- ->where('is_del','=',0)
- ->order('id asc')
- ->select();
-
-
- $this->assign('level_group_list',$level_group_list);
-
-
- $level_group_name = Db::name('archives')
- ->field('aid,typeid,title')
- ->where('typeid','=',$level_group_list[0]['id'])
- ->where('is_del','=',0)
- ->order('sort_order asc,aid asc')
- ->select();
- $this->assign('level_group_name',$level_group_name);
-
- $product_id = input('param.product_id/d', 0);
-
- $assign_data['product_id'] = $product_id;
-
-
-
- if((int)$typeid === 126 || (int)$typeid === 825 || (int)$typeid === 826){
-
- $product_tag = Db::name('archives')
- ->field('aid,typeid,title')
- ->where('typeid','=',58)
- ->where('is_del','=',0)
- ->order('sort_order asc,aid asc')
- ->select();
- }else{
-
- $cat = Db::name('arctype')->where(['parent_id'=>369,'article_id'=>$typeid])->find();
- if(empty($cat)){
- $cat_id = 371;
- }else{
- $cat_id = $cat['id'];
- }
- $product_tag = Db::name('archives')
- ->field('aid,typeid,title')
- ->where('typeid','=',$cat_id)
- ->where('is_del','=',0)
- ->order('sort_order asc,aid asc')
- ->select();
- }
- $this->assign('product_tag',$product_tag);
-
-
- $product_area = Db::name('citysite')->where(['level'=>1])->select();
- $this->assign('product_area_data',$product_area);
-
-
- $arctypeInfo = Db::name('arctype')->find($typeid);
-
- $topid = $arctypeInfo['topid'];
- $assign_data['topid'] = $topid;
-
-
- $catid = $arctypeInfo['area_id'];
-
- if((int)$catid === 0){
- $catid = input('param.catid/d', 0);
- }
- $assign_data['catid'] = $catid;
-
-
-
- $arctype_html = allow_release_arctype($typeid, array($this->channeltype),true,[],false,$catid);
- $assign_data['arctype_html'] = $arctype_html;
-
-
-
- $arcrank_list = get_arcrank_list();
- $assign_data['arcrank_list'] = $arcrank_list;
-
-
- $condition['ifcontrol'] = 0;
- $condition['channel_id'] = $this->channeltype;
- $channelfield_row = Db::name('channelfield')->where($condition)->field('name,ifeditable')->getAllWithIndex('name');
- $assign_data['channelfield_row'] = $channelfield_row;
-
-
-
- $archivesLogic = new \app\admin\logic\ArchivesLogic;
- $templateList = $archivesLogic->getTemplateList($this->nid);
- $this->assign('templateList', $templateList);
-
-
-
- $tempview = 'view_'.$this->nid.'.'.config('template.view_suffix');
- !empty($arctypeInfo['tempview']) && $tempview = $arctypeInfo['tempview'];
- $this->assign('tempview', $tempview);
-
-
-
- $globalConfig = tpCache('global');
- if (isset($globalConfig['other_arcclick']) && 0 <= $globalConfig['other_arcclick']) {
- $arcclick_arr = explode("|", $globalConfig['other_arcclick']);
- if (count($arcclick_arr) > 1) {
- $assign_data['rand_arcclick'] = mt_rand($arcclick_arr[0], $arcclick_arr[1]);
- } else {
- $assign_data['rand_arcclick'] = intval($arcclick_arr[0]);
- }
- }else{
- $arcclick_config['other_arcclick'] = '500|1000';
- tpCache('other', $arcclick_config);
- $assign_data['rand_arcclick'] = mt_rand(500, 1000);
- }
-
-
- $tpcache = config('tpcache');
- $assign_data['seo_pseudo'] = !empty($tpcache['seo_pseudo']) ? $tpcache['seo_pseudo'] : 1;
-
-
- $assign_data['archives_flags'] = model('ArchivesFlag')->getList();
- $channelRow = Db::name('channeltype')->where('id', $this->channeltype)->find();
- $assign_data['channelRow'] = $channelRow;
-
-
- $system_originlist = tpSetting('system.system_originlist');
- $system_originlist = json_decode($system_originlist, true);
- $system_originlist = !empty($system_originlist) ? $system_originlist : [];
- $assign_data['system_originlist_0'] = !empty($system_originlist) ? $system_originlist[0] : "";
- $assign_data['system_originlist_str'] = implode(PHP_EOL, $system_originlist);
-
-
- model('Citysite')->auto_location_select($assign_data);
-
- $this->assign($assign_data);
-
- return $this->fetch();
- }
-
-
-
- public function edit()
- {
- $admin_info = session('admin_info');
- $auth_role_info = $admin_info['auth_role_info'];
- $this->assign('auth_role_info', $auth_role_info);
- $this->assign('admin_info', $admin_info);
-
- if (IS_POST) {
- $post = input('post.');
- model('Archives')->editor_auto_210607($post);
- $post['aid'] = intval($post['aid']);
- $typeid = input('post.typeid/d', 0);
-
-
- if (!empty($post['tags_new'])) {
- $post['tags'] = !empty($post['tags']) ? $post['tags'] . ',' . $post['tags_new'] : $post['tags_new'];
- unset($post['tags_new']);
- }
- $post['tags'] = explode(',', $post['tags']);
- $post['tags'] = array_unique($post['tags']);
- $post['tags'] = implode(',', $post['tags']);
-
-
-
- $contentField = Db::name('channelfield')->where([
- 'channel_id' => $this->channeltype,
- 'dtype' => 'htmltext',
- ])->getField('name');
- $content = empty($post['addonFieldExt'][$contentField]) ? '' : htmlspecialchars_decode($post['addonFieldExt'][$contentField]);
-
-
-
- $seo_keywords = $post['seo_keywords'];
- if (!empty($seo_keywords)) {
- $seo_keywords = str_replace(',', ',', $seo_keywords);
- } else {
-
- }
-
-
- $is_remote = !empty($post['is_remote']) ? $post['is_remote'] : 0;
- $litpic = '';
- if ($is_remote == 1) {
- $litpic = $post['litpic_remote'];
- } else {
- $litpic = $post['litpic_local'];
- }
- if (empty($litpic)) {
- $litpic = get_html_first_imgurl($content);
- }
- $post['litpic'] = $litpic;
-
-
- if (empty($post['litpic'])) {
- $is_litpic = 0;
- } else {
- $is_litpic = !empty($post['is_litpic']) ? $post['is_litpic'] : 0;
- }
-
-
- $basic_update_seo_description = empty($post['basic_update_seo_description']) ? 0 : 1;
- if (is_language()) {
- $langRow = \think\Db::name('language')->order('id asc')
- ->cache(true, EYOUCMS_CACHE_TIME, 'language')
- ->select();
- foreach ($langRow as $key => $val) {
- tpCache('basic', ['basic_update_seo_description'=>$basic_update_seo_description], $val['mark']);
- }
- } else {
- tpCache('basic', ['basic_update_seo_description'=>$basic_update_seo_description]);
- }
-
-
-
- $seo_description = '';
- if (!empty($basic_update_seo_description) || empty($post['seo_description'])) {
- $seo_description = @msubstr(checkStrHtml($content), 0, config('global.arc_seo_description_length'), false);
- } else {
- $seo_description = $post['seo_description'];
- }
-
-
- $jumplinks = '';
- $is_jump = isset($post['is_jump']) ? $post['is_jump'] : 0;
- if (intval($is_jump) > 0) {
- $jumplinks = $post['jumplinks'];
- }
-
-
- if ($post['type_tempview'] == $post['tempview']) {
- unset($post['type_tempview']);
- unset($post['tempview']);
- }
-
-
- $channel = Db::name('arctype')->where(['id'=>$typeid])->getField('current_channel');
-
-
- $htmlfilename = trim($post['htmlfilename']);
- if (!empty($htmlfilename)) {
- $htmlfilename = preg_replace("/[^\x{4e00}-\x{9fa5}\w\-]+/u", "-", $htmlfilename);
-
-
- $map = [
- 'aid' => ['NEQ', $post['aid']],
- 'htmlfilename' => $htmlfilename,
- 'lang' => $this->admin_lang,
- ];
- if (!empty($post['typeid'])) {
- $map['typeid'] = array('eq', $post['typeid']);
- }
- $filenameCount = Db::name('archives')->where($map)->count();
- if (!empty($filenameCount)) {
- $this->error("同栏目下,自定义文件名已存在!");
- } else if (preg_match('/^(\d+)$/i', $htmlfilename)) {
- $this->error("自定义文件名不能纯数字,会与文档ID冲突!");
- }
- } else {
-
- if (is_dir('./weapp/Waimao/')) {
- $waimaoLogic = new \weapp\Waimao\logic\WaimaoLogic;
- $waimaoLogic->get_new_htmlfilename($htmlfilename, $post, 'edit', $this->globalConfig);
- }
- }
- $post['htmlfilename'] = $htmlfilename;
-
-
- if ($admin_info['role_id'] > 0 && $auth_role_info['check_oneself'] < 1) {
- $old_archives_arcrank = Db::name('archives')->where(['aid' => $post['aid']])->getField("arcrank");
- if ($old_archives_arcrank < 0) {
- unset($post['arcrank']);
- }
- }
-
-
- if (isset($post['stypeid'])) {
- $post['stypeid'] = preg_replace('/([^\d\,\,]+)/i', ',', $post['stypeid']);
- $post['stypeid'] = str_replace(',', ',', $post['stypeid']);
- $post['stypeid'] = trim($post['stypeid'], ',');
- $post['stypeid'] = str_replace(",{$typeid},", ',', ",{$post['stypeid']},");
- $post['stypeid'] = trim($post['stypeid'], ',');
- }
-
-
- $sort_order = Db::name('archives')->where('aid','=',(int)$post['level_group_name'])->value('sort_order');
-
-
-
- if(!empty($post['addonFieldExt']['down_eyou_remote'])){
- $file = explode('.',$post['addonFieldExt']['down_eyou_remote']);
- $ext = end($file);
- }else{
- $ext = '';
- }
-
-
-
- $newData = array(
- 'typeid'=> $typeid,
- 'channel' => $channel,
- 'is_b' => empty($post['is_b']) ? 0 : $post['is_b'],
- 'is_head' => empty($post['is_head']) ? 0 : $post['is_head'],
- 'is_special' => empty($post['is_special']) ? 0 : $post['is_special'],
- 'is_recom' => empty($post['is_recom']) ? 0 : $post['is_recom'],
- 'is_roll' => empty($post['is_roll']) ? 0 : $post['is_roll'],
- 'is_slide' => empty($post['is_slide']) ? 0 : $post['is_slide'],
- 'is_diyattr' => empty($post['is_diyattr']) ? 0 : $post['is_diyattr'],
- 'editor_remote_img_local'=> empty($post['editor_remote_img_local']) ? 0 : $post['editor_remote_img_local'],
- 'editor_img_clear_link' => empty($post['editor_img_clear_link']) ? 0 : $post['editor_img_clear_link'],
- 'is_jump' => $is_jump,
- 'is_litpic' => $is_litpic,
- 'jumplinks' => $jumplinks,
- 'seo_keywords' => $seo_keywords,
- 'seo_description' => $seo_description,
- 'crossed_price' => empty($post['crossed_price']) ? 0 : floatval($post['crossed_price']),
- 'add_time' => strtotime($post['add_time']),
- 'update_time' => getTime(),
- 'product_id' => (int)$post['product_id'],
- 'lunwen_id' => (int)$post['lunwen_id'],
- 'level_group_id' => (int)$post['level_group_id'],
- 'level_id' => (int)$post['level_group_name'],
- 'level' => (int)$sort_order,
- 'product_tag_id' => (int)$post['product_tag_id'],
- 'area_tag_id' => (int)$post['area_tag_id'],
- 'ext' => $ext
- );
- $data = array_merge($post, $newData);
-
- if((int)$typeid === 126 || (int)$typeid === 825 || (int)$typeid === 826){
-
-
- unset($data['province_id']);
- unset($data['city_id']);
- unset($data['area_id']);
- }
-
- if((int)$typeid === 117 || (int)$typeid === 115 || (int)$typeid === 111){
-
-
- unset($data['province_id']);
- unset($data['city_id']);
- unset($data['area_id']);
- }
-
- $arctype_par = Db::name('arctype')->field('id,parent_id')->where('id','=',$typeid)->find();
- if((int)$arctype_par['parent_id'] === 369){
-
-
- unset($data['province_id']);
- unset($data['city_id']);
- unset($data['area_id']);
- }
-
-
- $r = Db::name('archives')->where([
- 'aid' => $data['aid'],
- 'lang' => $this->admin_lang,
- ])->update($data);
-
- if ($r) {
-
- model('Custom')->afterSave($data['aid'], $data, 'edit', $this->table);
-
- adminLog('编辑文章:'.$data['title']);
-
-
- $numinfo = [
- 'is_del' => $data['is_del'],
- 'is_kan' => $data['arcrank'],
- 'status' => $data['status'],
- ];
-
-
- Db::name('seo_number')->where('aid','=',$data['aid'])->update($numinfo);
-
-
-
-
-
- $successData = [
- 'aid' => $data['aid'],
- 'tid' => $typeid,
- ];
- $this->success("操作成功!", null, $successData);
- }
- $this->error("操作失败!");
- }
-
- $assign_data = array();
-
- $id = input('id/d');
- $info = model('Custom')->getInfo($id, null, false);
- if (empty($info)) {
- $this->error('数据不存在,请联系管理员!');
- exit;
- }
-
- if (empty($info['channel'])) {
- $channelRow = Db::name('channeltype')->field('id as channel')
- ->where('id',$this->channeltype)
- ->find();
- $info = array_merge($info, $channelRow);
- }
-
- $typeid = $info['typeid'];
- $assign_data['typeid'] = $typeid;
-
-
-
- $list = Db::name('arctype_cat')
- ->where('parent_id','=',$typeid)
- ->where('type','=','产品')
- ->where('is_del','=',0)
- ->order('id asc')
- ->select();
-
-
- $this->assign('pro_list',$list);
-
-
-
- $level_group_list = Db::name('arctype')
- ->field('id,parent_id,typename')
- ->where('parent_id','=',53)
- ->where('is_del','=',0)
- ->order('id asc')
- ->select();
-
-
- $this->assign('level_group_list',$level_group_list);
-
-
- if((int)$info['level_group_id'] === 0){
- $level_group_id = $level_group_list[0]['id'];
- }else{
- $level_group_id = (int)$info['level_group_id'];
- }
- $level_group_name = Db::name('archives')
- ->field('aid,typeid,title')
- ->where('typeid','=',$level_group_id)
- ->where('is_del','=',0)
- ->order('sort_order asc,aid asc')
- ->select();
- $this->assign('level_group_name',$level_group_name);
-
- if((int)$typeid === 126 || (int)$typeid === 825 || (int)$typeid === 826){
-
- $product_tag = Db::name('archives')
- ->field('aid,typeid,title')
- ->where('typeid','=',58)
- ->where('is_del','=',0)
- ->order('sort_order asc,aid asc')
- ->select();
- }else{
-
- $cat = Db::name('arctype')->where(['parent_id'=>369,'article_id'=>$typeid])->find();
- if(empty($cat)){
- $cat_id = 371;
- }else{
- $cat_id = $cat['id'];
- }
- $product_tag = Db::name('archives')
- ->field('aid,typeid,title')
- ->where('typeid','=',$cat_id)
- ->where('is_del','=',0)
- ->order('sort_order asc,aid asc')
- ->select();
- }
- $this->assign('product_tag',$product_tag);
-
-
- $product_area = Db::name('citysite')->where(['level'=>1])->select();
- $this->assign('product_area_data',$product_area);
-
-
-
- $stypeid_arr = [];
- if (!empty($info['stypeid'])) {
- $info['stypeid'] = trim($info['stypeid'], ',');
- $stypeid_arr = Db::name('arctype')->field('id,typename')->where(['id'=>['IN', $info['stypeid']],'is_del'=>0])->select();
- }
- $assign_data['stypeid_arr'] = $stypeid_arr;
-
-
- $arctypeInfo = Db::name('arctype')->find($typeid);
-
- $topid = $arctypeInfo['topid'];
- $assign_data['topid'] = $topid;
-
- $info['channel'] = $arctypeInfo['current_channel'];
- if (is_http_url($info['litpic'])) {
- $info['is_remote'] = 1;
- $info['litpic_remote'] = handle_subdir_pic($info['litpic']);
- } else {
- $info['is_remote'] = 0;
- $info['litpic_local'] = handle_subdir_pic($info['litpic']);
- }
-
-
-
-
-
-
- $assign_data['field'] = $info;
-
-
- $arctype_html = allow_release_arctype($typeid, array($info['channel']));
- $assign_data['arctype_html'] = $arctype_html;
-
-
-
- $condition['ifcontrol'] = 0;
- $condition['channel_id'] = $this->channeltype;
- $channelfield_row = Db::name('channelfield')->where($condition)->field('name,ifeditable')->getAllWithIndex('name');
- $assign_data['channelfield_row'] = $channelfield_row;
-
-
-
- $arcrank_list = get_arcrank_list();
- $assign_data['arcrank_list'] = $arcrank_list;
-
-
- $archivesLogic = new \app\admin\logic\ArchivesLogic;
- $templateList = $archivesLogic->getTemplateList($this->nid);
- $this->assign('templateList', $templateList);
-
-
-
- $tempview = $info['tempview'];
- empty($tempview) && $tempview = $arctypeInfo['tempview'];
- $this->assign('tempview', $tempview);
-
-
-
- $tpcache = config('tpcache');
- $assign_data['seo_pseudo'] = !empty($tpcache['seo_pseudo']) ? $tpcache['seo_pseudo'] : 1;
-
-
- $assign_data['archives_flags'] = model('ArchivesFlag')->getList();
- $channelRow = Db::name('channeltype')->where('id', $this->channeltype)->find();
- $assign_data['channelRow'] = $channelRow;
-
-
- $system_originlist = tpSetting('system.system_originlist');
- $system_originlist = json_decode($system_originlist, true);
- $system_originlist = !empty($system_originlist) ? $system_originlist : [];
- $assign_data['system_originlist_str'] = implode(PHP_EOL, $system_originlist);
-
- $this->assign($assign_data);
- return $this->fetch();
- }
-
-
-
-
-
-
- public function del()
- {
- $archivesLogic = new \app\admin\logic\ArchivesLogic;
- $archivesLogic->del([], 0, 'custom');
- }
-
- public function help()
- {
- $system_originlist = tpSetting('system.system_originlist');
- $system_originlist = json_decode($system_originlist, true);
- $system_originlist = !empty($system_originlist) ? $system_originlist : [];
- $assign_data['system_originlist_str'] = implode(PHP_EOL, $system_originlist);
-
- $this->channeltype = input('param.channel/d', 0);
- $assign_data['channel'] = $this->channeltype ;
- $this->assign($assign_data);
-
-
- return $this->fetch();
- }
- }
|