Exemple #1
0
 public function _hd_field($attr, $content)
 {
     if (!isset($attr['model'])) {
         error('hd_field标签必须设置model属性。即模型表ID,如不清楚使用方式。请查看系统部署手册');
     }
     $model = intval($attr['model']);
     $type = 'add';
     //edit 编辑or发布
     if (isset($attr['type'])) {
         $type = $attr['type'];
     }
     $db = M('model');
     $mdata = $db->find($model);
     $upload = '';
     $validate = '';
     if ($mdata['upload']) {
         $upload = 'enctype="multipart/form-data"';
     }
     if ($mdata['validate']) {
         $validate = 'validate="true"';
     }
     $tpl = '{include file="' . PATH_ROOT . '/caches/model/model_' . $model . '_' . $type . '.html" /}';
     if (!file_exists(PATH_ROOT . '/caches/model/model_' . $model . '_' . $type . '.html')) {
         $field = new field($model);
         $field->build_field();
         header('Location:' . __URL__);
     }
     /*$tpl = '<?php include \'./caches/model/model_' . $model . '_' . $type . '.html\';?>';*/
     $str = '<form ' . $validate . ' method="post" action="' . __METH__ . '" ' . $upload . '>';
     if ($type == 'edit') {
         $str = '<?php if(is_array($field)){extract($field);}?><form ' . $validate . ' method="post" action="' . __METH__ . '" ' . $upload . ' />';
     }
     $str .= $tpl;
     $str .= $content;
     $str .= '</form>';
     return $str;
 }
Exemple #2
0
 /**
  * 更新修改和发布时的模板
  * 路径: PATH_ROOT . '/' . APP_GROUP . '/caches/model/model_';
  * @param type $model 模型ID
  */
 function updateStructTpl($model)
 {
     $field = new field($model);
     $field->build_field();
 }