qa-ifish7/web/Application/Admin/Model/PageModel.class.php

34 lines
1.3 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace Admin\Model;
use Think\Model;
class PageModel extends Model{
//自动验证
//array(验证字段,验证规则,错误提示,[验证条件,附加规则,验证时间])
protected $_validate = array(
array('name','require','请填写页面名称!',1),
array('classpath','checkPath','请填写栏目路径!',1,"callback"),
array('classpath','/^\/[\w|\.|\/]+\//','栏目名称不符号要求,只能使用[数字字母_/]',2),
array('classpath','','路径已存在',2,"unique"),
array('pagemod','require','缺少页面类型!',1),
array('pagetext','require','请填写页面内容!',1),
);
public function checkPath($val){
if(I("path_type")=="static"&&!$val){
return false;
}else{
return true;
}
}
//生成template文件
public function makePageTemplateFile($page_id){
$page_r=$this->find($page_id);
$TemplateModel=new \Admin\Model\TemplateModel();
$page_r["pagetext"]=$TemplateModel->replaceTemplate($page_r["pagetext"]);
file_put_contents(C("CMS_TEMP_PATH")."page_".$page_id.".html",$page_r["pagetext"]);
}
//删除模板文件
public function deletePageTemplateFile($page_id){
unlink(C("CMS_TEMP_PATH")."page_".$page_id.".html");
}
}