/**
  * @brief 渲染处理
  * @param string $viewFile 要渲染的页面
  * @param string or array $rdata 要渲染的数据
  */
 public function renderView($viewFile, $rdata = null)
 {
     //要渲染的视图
     $renderFile = $viewFile . $this->extend;
     //检查视图文件是否存在
     if (is_file($renderFile)) {
         //控制器的视图(需要进行编译编译并且生成可以执行的php文件)
         if (stripos($renderFile, IWEB_PATH . 'web/view/') === false) {
             //生成文件路径
             $runtimeFile = str_replace($this->getViewPath(), $this->module->getRuntimePath(), $viewFile . $this->defaultExecuteExt);
             //layout文件
             $layoutFile = $this->getLayoutFile() . $this->extend;
             if (!is_file($runtimeFile) || filemtime($renderFile) > filemtime($runtimeFile) || is_file($layoutFile) && filemtime($layoutFile) > filemtime($runtimeFile)) {
                 //获取view内容
                 $viewContent = file_get_contents($renderFile);
                 //处理layout
                 $viewContent = $this->renderLayout($layoutFile, $viewContent);
                 //标签编译
                 $inputContent = $this->tagResolve($viewContent);
                 //创建文件
                 $fileObj = new IFile($runtimeFile, 'w+');
                 $fileObj->write($inputContent);
                 $fileObj->save();
                 unset($fileObj);
             }
         } else {
             $runtimeFile = $renderFile;
         }
         //引入编译后的视图文件
         $this->requireFile($runtimeFile, $rdata);
     } else {
         return false;
     }
 }
Esempio n. 2
0
 /**
  * @brief 修改配置文件信息
  * @param string 配置文件名
  * @param array  写入的配置内容 key:配置信息里面key值; value:配置信息里面的value值
  * @return boolean
  */
 public static function edit($configFile, $inputArray)
 {
     //安全过滤要写入文件的内容
     foreach ($inputArray as $key => $val) {
         if (!in_array($key, self::$safeKey)) {
             $inputArray[$key] = IFilter::act($val, 'text');
         }
     }
     $configStr = "";
     //读取配置信息内容
     if (file_exists($configFile)) {
         $configStr = file_get_contents($configFile);
         $configArray = (require $configFile);
     }
     if (trim($configStr) == "") {
         $configStr = "<?php return array( \r\n);?>";
         $configArray = array();
     }
     //表单中存在但是不进行录用的键值
     $except = array('form_index');
     foreach ($except as $value) {
         unset($inputArray[$value]);
     }
     $inputArray = array_merge($configArray, $inputArray);
     $configData = var_export($inputArray, true);
     $configStr = "<?php return {$configData}?>";
     //写入配置文件
     $fileObj = new IFile($configFile, 'w+');
     $writeResult = $fileObj->write($configStr);
     return $writeResult;
 }
Esempio n. 3
0
 /**
  * @brief 订单打印模板修改保存
  */
 public function print_template_update()
 {
     // 获取POST数据
     $con_shop = IReq::get("con_shop");
     $con_pick = IReq::get("con_pick");
     //获取根目录路径
     $path = IWeb::$app->getBasePath() . 'views/' . $this->theme . '/order';
     //保存 购物清单模板
     $ifile_shop = new IFile($path . '/shop_template.html', 'w');
     if (!$ifile_shop->write($con_shop)) {
         $this->redirect('print_template', false);
         Util::showMessage('保存购物清单模板失败!');
     }
     //保存 配货单模板
     $ifile_pick = new IFile($path . "/pick_template.html", 'w');
     if (!$ifile_pick->write($con_pick)) {
         $this->redirect('print_template', false);
         Util::showMessage('保存配货单模板失败!');
     }
     //保存 合并单模板
     $ifile_merge = new IFile($path . "/merge_template.html", 'w');
     if (!$ifile_merge->write($con_shop . $con_pick)) {
         $this->redirect('print_template', false);
         Util::showMessage('购物清单和配货单模板合并失败!');
     }
     $this->setRenderData(array('where' => ''));
     $this->redirect('order_list');
 }
Esempio n. 4
0
 function writeFile($fileName, $content)
 {
     $fileObj = new IFile($fileName, 'a+');
     $fileObj->write($content);
 }
Esempio n. 5
0
    function ticket_excel()
    {
        //代金券excel表存放地址
        $fileName = $this->ticketDir . '/t' . date('YmdHis') . IHash::random(8) . '.xls';
        $ticket_id = IFilter::act(IReq::get('id'));
        $ticket_id_array = array();
        if (!empty($ticket_id)) {
            $excelStr = '<table><tr><th>名称</th><th>卡号</th><th>密码</th><th>面值</th>
			<th>已被使用</th><th>是否关闭</th><th>是否发送</th><th>开始时间</th><th>结束时间</th></tr>';
            $propObj = new IModel('prop');
            $where = 'type = 0';
            if (is_array($ticket_id)) {
                $ticket_id_array = $ticket_id;
            } else {
                $ticket_id_array[] = $ticket_id;
            }
            //当代金券数量没有时不允许备份excel
            foreach ($ticket_id_array as $key => $tid) {
                if ($this->getTicketCount($propObj, $tid) == 0) {
                    unset($ticket_id_array[$key]);
                }
            }
            if ($ticket_id_array) {
                $id_num_str = join('","', $ticket_id_array);
            } else {
                $this->redirect('ticket_list', false);
                Util::showMessage('实体代金券数量为0张,无法备份');
                exit;
            }
            $where .= ' and `condition` in("' . $id_num_str . '")';
            $propList = $propObj->query($where, '*', '`condition`', 'asc', '10000');
            foreach ($propList as $key => $val) {
                $is_userd = $val['is_userd'] == '1' ? '是' : '否';
                $is_close = $val['is_close'] == '1' ? '是' : '否';
                $is_send = $val['is_send'] == '1' ? '是' : '否';
                $excelStr .= '<tr>';
                $excelStr .= '<td>' . $val['name'] . '</td>';
                $excelStr .= '<td>' . $val['card_name'] . '</td>';
                $excelStr .= '<td>' . $val['card_pwd'] . '</td>';
                $excelStr .= '<td>' . $val['value'] . ' 元</td>';
                $excelStr .= '<td>' . $is_userd . '</td>';
                $excelStr .= '<td>' . $is_close . '</td>';
                $excelStr .= '<td>' . $is_send . '</td>';
                $excelStr .= '<td>' . $val['start_time'] . '</td>';
                $excelStr .= '<td>' . $val['end_time'] . '</td>';
                $excelStr .= '</tr>';
            }
            $excelStr .= '</table>';
            $fileObj = new IFile($fileName, 'w+');
            $fileObj->write($excelStr);
            $this->ticket_excel_list();
        } else {
            $this->redirect('ticket_list', false);
            Util::showMessage('请选择要操作的文件');
        }
    }
Esempio n. 6
0
 /**
  * @brief 修改配置文件信息
  * @param string 配置文件名
  * @param array  写入的配置内容 key:配置信息里面key值; value:配置信息里面的value值
  */
 public static function edit($configFile, $inputArray)
 {
     //安全过滤要写入文件的内容
     $configStr = "";
     //读取配置信息内容
     if (file_exists($configFile)) {
         $configStr = file_get_contents($configFile);
         $configArray = (include $configFile);
     } else {
         @fopen($configFile, "w");
     }
     if (trim($configStr) == "") {
         $configStr = "<?php return array( \r\n);?>";
         $configArray = array();
     }
     //表单中存在但是不进行录用的键值
     $except = array('form_index');
     foreach ($except as $value) {
         unset($inputArray[$value]);
     }
     $inputArray = array_merge($configArray, $inputArray);
     $configData = var_export($inputArray, true);
     $configStr = "<?php return {$configData}?>";
     //写入配置文件
     $fileObj = new IFile($configFile, 'w+');
     $fileObj->write($configStr);
 }
Esempio n. 7
0
 public function savemembergrade()
 {
     $gradename = IFilter::act(IReq::get('gradename'));
     $from = IFilter::act(IReq::get('from'));
     $to = IFilter::act(IReq::get('to'));
     if (!is_array($gradename)) {
         $this->message('登记名称不是数组');
     }
     if (count($gradename) != count($from)) {
         $this->message('等级名称个数和起始积分个数不相等');
     }
     if (count($gradename) != count($to)) {
         $this->message('等级名称个数和结束积分个数不相等');
     }
     $newarray = array();
     foreach ($gradename as $key => $value) {
         $temp['gradename'] = $value;
         $temp['from'] = $from[$key];
         $temp['to'] = $to[$key];
         $newarray[] = $temp;
     }
     $configData = var_export($newarray, true);
     $configStr = '<?php return ' . $configData . '?>';
     $fileObj = new IFile(hopedir . '/config/membergrade.php', 'w+');
     $fileObj->write($configStr);
     $this->success('操作成功!');
 }