Ejemplo n.º 1
0
 /**
  * 根据模型id 自定义表单自动输出
  * @param $id int 模型ID
  * @param $fields array 想要输出的字段名称(可在后台的 模型->模型设置->模型字段 中获得)
  * $html 直接输出自定义输出的表单
  * 例:show_extern_form(2,array('content','name','qq'));
  * 注: 参数二中键越小的字段输出越靠前
  */
 public function show_extern_form($id, $fields = array())
 {
     if (!is_array($fields)) {
         return false;
     }
     $extern = $this->externs[$id];
     $attr = $extern['attr_content'];
     if (!empty($fields)) {
         $attr = array();
         foreach ($fields as $vf) {
             foreach ($extern['attr_content'] as $k => $v) {
                 if ($v['field'] == $vf) {
                     $attr[$k] = $v;
                 }
             }
         }
     }
     $html = '';
     foreach ($attr as $k => $v) {
         $html .= '<tr>' . '<td>' . $v['title'] . ':</td>' . '<td>' . form_auto($v) . '</td></tr>';
     }
     echo $html;
 }
Ejemplo n.º 2
0
/**
 * 根据分类ID,返回扩展模型的HTML表单结构
 *
 * @param  $cate_id 分类ID
 */
function show_extern_html($extern_id, $field = array())
{
    global $c;
    $extern = $c->externs[$extern_id];
    $attr = $extern['attr_content'];
    foreach ($attr as $k => $a) {
        if (isset($field) && count($field) > 0) {
            if (!in_array($a['field'], $field)) {
                continue;
            }
        }
        if ($k == 0 || $k == count($attr) - 1) {
            $fstyle = ' style="height:50px;"';
        } else {
            $fstyle = '';
        }
        echo '<tr' . $fstyle . '>';
        if (helper::from_mobile()) {
            echo '<td style="text-indent:10px;">' . $a['title'] . ':</td>';
        } else {
            echo '<td style="text-indent:10px;width:110px;">' . $a['title'] . ':</td>';
        }
        echo '<td>';
        echo form_auto($a, '');
        echo '</td>';
        echo '</tr>';
    }
}