Ejemplo n.º 1
0
 /**
  * 生成表单html
  */
 protected function createForm($mid, $data)
 {
     if (empty($data) || empty($mid)) {
         return false;
     }
     if ($data['status'] != 1) {
         return false;
     }
     $url = substr(form_show_url($mid, $data), strlen(Controller::get_base_url()));
     //去掉域名部分
     if (substr($url, -5) != '.html') {
         $file = 'index.html';
         //文件名
         $dir = $url;
         //目录
     } else {
         $file = basename($url);
         $dir = str_replace($file, '', $url);
     }
     $this->mkdirs($dir);
     $dir = substr($dir, -1) == '/' ? substr($dir, 0, -1) : $dir;
     $htmlfile = $dir ? $dir . '/' . $file : $file;
     ob_start();
     $model = $this->get_model('form');
     $form = $model[$mid];
     if (empty($form)) {
         return false;
     }
     if (!isset($form['setting']['form']['url']['tohtml']) || empty($form['setting']['form']['url']['tohtml'])) {
         return false;
     }
     if (isset($form['fields']) && $form['fields']) {
         $data = $this->getFieldData($form, $data);
     }
     $this->view->assign($data);
     $this->view->assign(array('table' => $form['tablename'], 'modelid' => $mid, 'form_name' => $form['modelname'], 'meta_title' => $form['setting']['form']['meta_title'], 'meta_keywords' => $form['setting']['form']['meta_keywords'], 'meta_description' => $form['setting']['form']['meta_description']));
     if ($this->namespace == 'admin') {
         $this->view->setTheme(true);
     }
     $this->view->display(substr($form['showtpl'], 0, -5));
     if ($this->namespace == 'admin') {
         $this->view->setTheme(false);
     }
     if (!file_put_contents($htmlfile, ob_get_clean(), LOCK_EX)) {
         $this->adminMsg(lang('a-com-11', array('1' => $htmlfile)));
     }
     $htmlfiles = $this->cache->get('html_files');
     $htmlfiles[] = $htmlfile;
     $this->cache->set('html_files', $htmlfiles);
     return true;
 }
Ejemplo n.º 2
0
 public function formAction()
 {
     $cid = (int) $this->get('cid');
     $type = (int) $this->get('type');
     $page = $this->get('page') ? (int) $this->get('page') : 1;
     $status = isset($_GET['status']) ? (int) $this->get('status') : -1;
     $modelid = (int) $this->get('modelid');
     if (!isset($this->form[$modelid]) || empty($this->form[$modelid])) {
         $this->memberMsg(lang('m-con-24'));
     }
     $table = $this->model($this->form[$modelid]['tablename']);
     if ($this->isPostForm() && $this->post('ids')) {
         //删除
         $ids = '';
         foreach ($this->post('ids') as $i) {
             $ids .= ',' . (int) $i;
         }
         $ids = trim($ids, ',');
         if (empty($ids)) {
             $this->memberMsg(lang('m-con-25'));
         }
         $data = $table->where("userid=" . $this->memberinfo['id'] . " and username='******'username'] . "' and id in(" . $ids . ")")->select();
         if (empty($data)) {
             $this->memberMsg(lang('m-con-25'));
         }
         foreach ($data as $t) {
             $file = substr(form_show_url($modelid, $t), strlen(Controller::get_base_url()));
             //去掉主域名
             $file = substr($file, 0, 9) == 'index.php' ? null : $file;
             //是否为动态链接
             if ($file && file_exists($file)) {
                 @unlink($file);
             }
             $table->update(array('status' => 3), 'id=' . $t['id']);
         }
     }
     $showme = isset($this->form[$modelid]['joinid']) && isset($this->form[$modelid]['setting']['form']['showme']) ? $this->form[$modelid]['setting']['form']['showme'] : 0;
     $pagelist = $this->instance('pagelist');
     $pagelist->loadconfig();
     $pagesize = isset($this->memberconfig['pagesize']) && $this->memberconfig['pagesize'] ? $this->memberconfig['pagesize'] : 8;
     if ($this->form[$modelid]['joinid'] && $type && $showme) {
         $where = empty($cid) ? '`cid` IN (SELECT `id` FROM `' . $this->content->prefix . 'content_' . $this->siteid . '` WHERE `modelid`=' . $this->form[$modelid]['joinid'] . ' AND `sysadd`=0 AND `status`>0 AND `userid`=' . $this->memberinfo['id'] . ' AND `username`="' . $this->memberinfo['username'] . '")' : '`cid` IN (SELECT `id` FROM `' . $this->content->prefix . 'content_' . $this->siteid . '` WHERE `modelid`=' . $this->form[$modelid]['joinid'] . ' AND `sysadd`=0 AND `status`>0 AND `userid`=' . $this->memberinfo['id'] . ' AND `username`="' . $this->memberinfo['username'] . '" AND id=' . $cid . ')';
     } else {
         $where = (empty($cid) ? '' : '`cid`=' . $cid . ' AND ') . '`userid`=' . $this->memberinfo['id'] . ' AND `username`="' . $this->memberinfo['username'] . '"';
     }
     $where .= $status > 0 && $status < 3 ? ' AND `status`=' . $status : '';
     $data = $table->page_limit($page, $pagesize)->order('updatetime DESC')->where($where)->select();
     $total = $table->count($this->form[$modelid]['tablename'], 'id', $where);
     $pagelist = $pagelist->total($total)->url(url('member/content/form', array('modelid' => $modelid, 'type' => $type, 'status' => $status, 'page' => '{page}')))->num($pagesize)->page($page)->output();
     $this->view->assign(array('list' => $data, 'page' => $page, 'type' => $type, 'form' => $this->form[$modelid], 'join' => $this->form[$modelid]['joinid'] ? $this->form[$modelid]['joinname'] : 0, 'status' => $status, 'showme' => $showme, 'modelid' => $modelid, 'pagelist' => $pagelist, 'listdata' => $data, 'meta_title' => $this->form[$modelid]['joinname'] . $this->form[$modelid]['modelname'] . '-' . lang('member') . '-' . $this->site['SITE_NAME'], 'showfields' => isset($this->form[$modelid]['setting']['form']['membershow']) ? $this->form[$modelid]['setting']['form']['membershow'] : array()));
     $this->view->display('member/form_list');
 }
        if (date('Y-m-d', $t['updatetime']) == date('Y-m-d')) {
            ?>
color:#F00<?php 
        }
        ?>
"><?php 
        echo date(TIME_FORMAT, $t['updatetime']);
        ?>
</span></td>
    <td align="left">
    <?php 
        $del = url('admin/form/del/', array('modelid' => $modelid, 'id' => $t['id'], 'cid' => $cid));
        ?>
    <a href="<?php 
        echo $site_url;
        echo form_show_url($modelid, $t);
        ?>
" target="_blank"><?php 
        echo lang('a-cat-23');
        ?>
</a> |
    <?php 
        if (admin_auth($userinfo['roleid'], 'form-edit')) {
            ?>
<a href="<?php 
            echo url('admin/form/edit', array('id' => $t['id'], 'modelid' => $modelid, 'cid' => $cid));
            ?>
"><?php 
            echo lang('a-edit');
            ?>
</a> | <?php 
Ejemplo n.º 4
0
 /**
  * 删除静态文件
  */
 private function delFile($id)
 {
     $data = $this->form->find((int) $id);
     $file = substr(form_show_url($this->modelid, $data), strlen(Controller::get_base_url()));
     //去掉主域名
     $file = substr($file, 0, 9) == 'index.php' ? null : $file;
     //是否为动态链接
     if ($file && file_exists($file)) {
         @unlink($file);
     }
 }