Special.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace app\home\controller;
  3. use think\facade\View;
  4. use think\facade\Lang;
  5. /**
  6. * ============================================================================
  7. *
  8. * ============================================================================
  9. *
  10. * ----------------------------------------------------------------------------
  11. *
  12. * ============================================================================
  13. * 控制器
  14. */
  15. class Special extends BaseMall {
  16. public function initialize() {
  17. parent::initialize();
  18. Lang::load(base_path() . 'home/lang/'.config('lang.default_lang').'/special.lang.php');
  19. Lang::load(base_path() . 'admin/lang/'.config('lang.default_lang').'/editable_page.lang.php');
  20. }
  21. public function index() {
  22. $editable_page_id = intval(input('param.special_id'));
  23. $editable_page_model = model('editable_page');
  24. $editable_page_info = $editable_page_model->getOneEditablePage(array('editable_page_id' => $editable_page_id));
  25. if (!$editable_page_info) {
  26. $this->error(lang('param_error'));
  27. }
  28. $editable_page_info['editable_page_theme_config'] = json_decode($editable_page_info['editable_page_theme_config'], true);
  29. View::assign('editable_page', $editable_page_info);
  30. $editable_page_config_model = model('editable_page_config');
  31. $editable_page_config_list=$editable_page_config_model->getEditablePageConfigList(array(array('editable_page_id', '=', $editable_page_id)));
  32. $config_list=array();
  33. foreach($editable_page_config_list as $key => $val){
  34. $config_info=json_decode($val['editable_page_config_content'], true);
  35. $model_id=$val['editable_page_model_id'];
  36. $var_html=array();
  37. if(!empty($config_info)){
  38. require_once PLUGINS_PATH.'/editable_page_model/'.$model_id.'/config.php';
  39. $model_name='Model'.$model_id;
  40. $model=new $model_name();
  41. $res=$model->filterData($config_info);
  42. if($res['code']){
  43. $res=$model->formatData(json_encode($res['data']));
  44. if($res['code']){
  45. $var_html['config_info']=$res['data'];
  46. }
  47. }
  48. }
  49. $html=View::fetch('../../../plugins/editable_page_model/'.$model_id.'/index',$var_html);
  50. $config_list[]=array(
  51. 'val'=>$val,
  52. 'html'=>$html,
  53. );
  54. }
  55. View::assign('config_list', $config_list);
  56. return View::fetch($this->template_dir . 'index');
  57. }
  58. }