123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322 |
- <?php
-
-
- namespace weapp\MakemHtml\controller;
-
- use think\Page;
- use think\Db;
- use app\common\controller\Weapp;
- use weapp\MakemHtml\model\MakemHtmlModel;
- use think\Cache;
- use app\common\logic\ArctypeLogic;
- use app\admin\controller\Base;
-
-
- class MakemHtml extends Weapp
- {
-
-
- private $model;
-
-
-
- private $db;
-
-
-
- private $weappInfo;
-
-
-
- public function __construct(){
- parent::__construct();
- $this->model = new MakemHtmlModel;
- $this->db = Db::name('WeappMakemHtml');
-
-
- $this->weappInfo = $this->getWeappInfo();
- $this->assign('weappInfo', $this->weappInfo);
-
- }
-
-
- public function doc()
- {
- return $this->fetch();
- }
-
-
-
- public function conf()
- {
- $inc_type = 'seo';
- $config = tpCache($inc_type);
- $config['seo_pseudo'] = tpCache('seo.seo_pseudo');
- $templateConfig['view_path'] = "./template/".TPL_THEME."mobile/";
-
- if(!file_exists($templateConfig['view_path'])){
- $templateerror = 1;
- $this->assign('templateerror', $templateerror);
-
- }
-
- if($config['seo_pseudo']!=2){
- $conf_seo_pseudo = 1;
- $this->assign('conf_seo_pseudo', $conf_seo_pseudo);
- }
-
-
- if (IS_POST) {
- $seo_html_arcdir= M('config')->where('id',227)->value('value');
- $post = input('post.');
- $post['value1'] = $seo_html_arcdir;
-
- $r = Db::name('weapp_makemhtml')
- ->where('id',1)
- ->update($post);
-
- if ($r) {
- $this->success("操作成功!", weapp_url('MakemHtml/MakemHtml/conf'));
- }
-
- $this->success("操作成功!");
- }
- $seo_html_arcdir = $config['seo_html_arcdir']!=''?substr($config['seo_html_arcdir'],1):'html';
-
- $row = M('weapp_makemhtml')->where(1)->find();
- $this->assign('row', $row);
- $this->assign('seo_html_arcdir', $seo_html_arcdir);
- return $this->fetch('conf');
- }
-
-
- public function build(){
- $config = tpCache('seo');
- $row = M('weapp_makemhtml')->where(1)->value('value');
- $row = !empty($row) ? $row : '/m';
- $config['seo_html_position']='..'.$row.'/index.html';
-
- $this->assign('config',$config);
-
-
- $map = array(
- 'status' => 1,
- 'is_del' => 0,
- 'current_channel' => ['neq', 51],
- 'weapp_code' => '',
- );
- $arctypeLogic = new ArctypeLogic();
- $select_html = $arctypeLogic->arctype_list(0, 0, true, config('global.arctype_max_level'), $map);
- $this->assign('select_html',$select_html);
-
- $arc_select_html = allow_release_arctype();
- $this->assign('arc_select_html', $arc_select_html);
- $row = M('weapp_makemhtml')->where('id',1)->value('value');
- $this->assign('row', $row);
-
- return $this->fetch();
- }
-
-
-
- public function index()
- {
-
-
-
- $this->correctArctypeDirpath();
-
-
- $inc_type = 'seo';
- $config = tpCache($inc_type);
- $config['seo_pseudo'] = tpCache('seo.seo_pseudo');
- $seo_pseudo_list = get_seo_pseudo_list();
- $this->assign('seo_pseudo_list', $seo_pseudo_list);
- $templateConfig['view_path'] = "./template/".TPL_THEME."mobile/index.htm";
-
- if(!file_exists($templateConfig['view_path'])){
-
- $templateerror = 1;
- $this->assign('templateerror', $templateerror);
- }
- if($config['seo_pseudo']!=2){
- $conf_seo_pseudo = 1;
- $this->assign('conf_seo_pseudo', $conf_seo_pseudo);
- }
-
-
- $seo_pseudo_lang = '';
- $web_language_switch = tpCache('web.web_language_switch');
- if (is_language() && !empty($web_language_switch)) {
- $markArr = Db::name('language')->field('mark')->order('id asc')->limit('1,1')->select();
- if (!empty($markArr[0]['mark'])) {
- $seo_pseudo_lang = tpCache('seo.seo_pseudo', [], $markArr[0]['mark']);
- }
- $seo_pseudo_lang = !empty($seo_pseudo_lang) ? $seo_pseudo_lang : 1;
- }
- $this->assign('seo_pseudo_lang', $seo_pseudo_lang);
-
-
-
- $wwwroot_dir = config('global.wwwroot_dir');
- $disable_dirname = config('global.disable_dirname');
- $wwwroot_dir = array_merge($wwwroot_dir, $disable_dirname);
-
- $arctypeDirnames = Db::name('arctype')->where(['parent_id'=>0])->column('dirname');
- is_array($arctypeDirnames) && $wwwroot_dir = array_merge($wwwroot_dir, $arctypeDirnames);
-
- $markArr = Db::name('language_mark')->column('mark');
- is_array($markArr) && $wwwroot_dir = array_merge($wwwroot_dir, $markArr);
- $wwwroot_dir = array_unique($wwwroot_dir);
- $this->assign('seo_html_arcdir_limit', implode(',', $wwwroot_dir));
-
-
- $seo_html_arcdir_1 = '';
- if (!empty($config['seo_html_arcdir'])) {
- $config['seo_html_arcdir'] = trim($config['seo_html_arcdir'], '/');
- $seo_html_arcdir_1 = '/'.$config['seo_html_arcdir'];
- }
- $this->assign('seo_html_arcdir_1', $seo_html_arcdir_1);
-
-
- $map = array(
- 'status' => 1,
- 'is_del' => 0,
- 'current_channel' => ['neq', 51],
- 'weapp_code' => '',
- );
- $arctypeLogic = new ArctypeLogic();
- $select_html = $arctypeLogic->arctype_list(0, 0, true, config('global.arctype_max_level'), $map);
-
- $this->assign('select_html',$select_html);
-
- $arc_select_html = allow_release_arctype();
- $this->assign('arc_select_html', $arc_select_html);
-
- $this->buildhtml_clear_cache();
-
-
- if (!isset($config['seo_html_arcdir'])) {
- $init_html = 1;
- } else {
- $init_html = 2;
- }
-
- $cms_version = getCmsVersion();
- $min_version = 'v1.5.7';
- if ($cms_version < $min_version) {
- $this->error('当前CMS版本太低,该插件要求CMS版本 >= ' . $min_version . ',请升级系统!');
- }
-
-
-
- $row = M('weapp_makemhtml')->where('id',1)->find();
- $this->assign('row', $row['value']);
- $this->assign('seo_html_arcdir',$row['value1']);
-
- $this->assign('init_html', $init_html);
-
-
- $this->assign('config',$config);
- return $this->fetch();
- }
-
-
- private function correctArctypeDirpath()
- {
- $system_correctArctypeDirpath = tpCache('system.system_correctArctypeDirpath');
- if (!empty($system_correctArctypeDirpath)) {
- return false;
- }
-
- $saveData = [];
- $arctypeList = Db::name('arctype')->field('id,parent_id,dirname,dirpath,grade')
- ->order('grade asc')
- ->getAllWithIndex('id');
- foreach ($arctypeList as $key => $val) {
- if (empty($val['parent_id'])) {
- $saveData[] = [
- 'id' => $val['id'],
- 'dirpath' => '/'.$val['dirname'],
- 'grade' => 0,
- 'update_time' => getTime(),
- ];
- } else {
- $parentRow = $arctypeList[$val['parent_id']];
- if (empty($parentRow['parent_id'])) {
- $saveData[] = [
- 'id' => $val['id'],
- 'dirpath' => '/'.$parentRow['dirname'].'/'.$val['dirname'],
- 'grade' => 1,
- 'update_time' => getTime(),
- ];
- } else {
- $topRow = $arctypeList[$parentRow['parent_id']];
- $saveData[] = [
- 'id' => $val['id'],
- 'dirpath' => '/'.$topRow['dirname'].'/'.$parentRow['dirname'].'/'.$val['dirname'],
- 'grade' => 2,
- 'update_time' => getTime(),
- ];
- }
- }
- }
- $r = model('Arctype')->saveAll($saveData);
- if (false !== $r) {
-
- if (is_language()) {
- $langRow = \think\Db::name('language')->order('id asc')
- ->cache(true, EYOUCMS_CACHE_TIME, 'language')
- ->select();
- foreach ($langRow as $key => $val) {
- tpCache('system', ['system_correctArctypeDirpath'=>1],$val['mark']);
- }
- } else {
- tpCache('system',['system_correctArctypeDirpath'=>1]);
- }
-
- }
- }
-
-
-
-
- private function buildhtml_clear_cache()
- {
-
- cache("article_info_serialize",null);
- cache("article_page_total_serialize",null);
- cache("article_content_serialize",null);
- cache("article_tags_serialize",null);
- cache("article_attr_info_serialize",null);
- cache("article_children_row_serialize",null);
-
- cache("channel_page_total_serialize",null);
- cache("channel_info_serialize",null);
- cache("has_children_Row_serialize",null);
- }
-
-
-
- }
|