예제 #1
0
 /**
  * 添加/编辑分类
  */
 public function action()
 {
     $categoryId = $this->g('id');
     if (empty($categoryId)) {
         $this->assign('method', 'POST');
         if ($parent = $this->g('parent')) {
             $this->assign('category_parent', $parent);
             $this->assign('title', '添加子分类');
         } else {
             $this->assign('title', '添加分类');
         }
         $tree = \Model\Category::getSelectCate(array($parent));
     } else {
         $category = \Model\Category::listCategory($categoryId);
         if (empty($category)) {
             $this->error('分类不存在');
         }
         $tree = \Model\Category::getSelectCate(array($category['category_parent']));
         $this->assign('method', 'PUT');
         $this->assign($category);
         $this->assign('title', '编辑分类');
     }
     $this->assign('model', \Model\Content::listContent(['table' => 'model', 'condition' => 'model_attr = 1']));
     $this->assign('tree', $tree);
     $this->layout();
 }
예제 #2
0
 /**
  * 生成对应的HTML表单内容
  * @param type $field 提交过来的字段
  */
 public function formList($field)
 {
     switch ($field['field_type']) {
         case 'text':
             require 'theme/text.php';
             break;
         case 'textarea':
             require 'theme/textarea.php';
             break;
         case 'editor':
             /**
              * 将属于必填项的表单名称写入数组
              * 在模板的底部进行一个JS的校验.
              */
             static $checkEditor, $checkEditorName;
             if ($field['field_required'] == '1') {
                 /* 表单名称 */
                 $checkEditor[] = $field['field_name'];
                 /* 显示名称 */
                 $checkEditorName[] = $field['display_name'];
             }
             require 'theme/editor.php';
             break;
         case 'date':
             require 'theme/date.php';
             break;
         case 'radio':
             require 'theme/radio.php';
             break;
         case 'checkbox':
             require 'theme/checkbox.php';
             break;
         case 'thumb':
             require 'theme/thumb.php';
             break;
         case 'category':
             \Model\Category::$where = 'm.model_name = "' . MODULE . '"';
             $tree = \Model\Category::getSelectCate($field['value'] ? array($field['value']) : '', true);
             require 'theme/category.php';
             break;
         case 'select':
             require 'theme/select.php';
             break;
         case 'file':
             require 'theme/file.php';
             break;
         case 'img':
             require 'theme/img.php';
             break;
     }
 }
예제 #3
0
 /**
  * 生成对应的HTML表单内容
  * @param type $field 提交过来的字段
  */
 public function formList($field)
 {
     switch ($field['field_type']) {
         case 'text':
             require 'theme/text.php';
             break;
         case 'textarea':
             require 'theme/textarea.php';
             break;
         case 'editor':
             /**
              * 将属于必填项的表单名称写入数组
              * 在模板的底部进行一个JS的校验.
              */
             static $checkEditor, $checkEditorName;
             if ($field['field_required'] == '1') {
                 /* 表单名称 */
                 $checkEditor[] = $field['field_name'];
                 /* 显示名称 */
                 $checkEditorName[] = $field['field_display_name'];
             }
             require 'theme/editor.php';
             break;
         case 'date':
             require 'theme/date.php';
             break;
         case 'radio':
             require 'theme/radio.php';
             break;
         case 'checkbox':
             require 'theme/checkbox.php';
             break;
         case 'thumb':
             require 'theme/thumb.php';
             break;
         case 'category':
             \Model\Category::$where = 'm.model_name = "' . MODULE . '"';
             $tree = \Model\Category::getSelectCate($field['value'] ? array($field['value']) : array(), true);
             require 'theme/category.php';
             break;
         case 'select':
             require 'theme/select.php';
             break;
         case 'file':
             require 'theme/file.php';
             break;
         case 'img':
             require 'theme/img.php';
             break;
         case 'theme':
             $themeName = THEME . '/Home/' . \Core\Func\CoreFunc::getThemeName('Home') . '/' . MODULE;
             $themeList = scandir($themeName);
             $theme = ['默认模板' => ''];
             foreach ($themeList as $value) {
                 if ($value != '.' && $value != '..' && $value != '.DS_Store') {
                     $value = str_replace('.php', '', $value);
                     $theme[$value] = $value;
                 }
             }
             $field['field_option'] = json_encode($theme);
             require 'theme/select.php';
             break;
     }
 }