源码示例文件
1数据展示类 dirname.class.php
<?php
class dirname{
public static $config,$language,$table_pre,$module_config;
function __construct($pdo){
if(!self::$config){
//echo 'construct<br>';
global $config,$language,$page;
$program=__CLASS__;
$program_config=require './program/'.$program.'/config.php';
$program_language=require './program/'.$program.'/language/'.$program_config['program']['language'].'.php';
self::$config=array_merge($config,$program_config);
self::$language=array_merge($language,$program_language);
self::$table_pre=$pdo->sys_pre.self::$config['class_name']."_";
self::$module_config=require './program/'.$program.'/module_config.php';
}
}
function __call($method,$args){
$pdo=$args[0];
$call=$method;
$class=__CLASS__;
$method=$class."::".$method;
if(in_array($class.'.'.$call,self::$config['program_unlogin_function_power'])){$m_require_login=0;}else{$m_require_login=1;}
require './program/'.$class.'/show/'.$call.'.php';
}
//=======================================================================================================设置 monxin=dir.show 页面标题
function show_head_data($pdo){
$id=intval(@$_GET['id']);
if($id>0){
$sql="select `type`,`title` from ".self::$table_pre."* where `id`='$id' and `visible`=1";
$r=$pdo->query($sql,2)->fetch(2);
$r=de_safe_str($r);
$r['title'].='-'.self::get_type_title($pdo,$r['type']);
$v['title']=$r['title'];
$v['keywords']=$r['title'];
$v['description']=$r['title'];
return $v;
}
}
}
?>2数据接收处理类 receive.class.php
<?php
class receive{
public static $config,$language,$table_pre;
function __construct($pdo){
if(!self::$config){
//echo 'construct<br>';
global $config,$language,$program,$page;
$program_config=require_once './program/'.$program.'/config.php';
$program_language=require_once './program/'.$program.'/language/'.$program_config['program']['language'].'.php';
self::$config=array_merge($config,$program_config);
self::$language=array_merge($language,$program_language);
self::$table_pre=$pdo->sys_pre.self::$config['class_name']."_";
}
}
function __call($method,$args){
//var_dump( $args);
@require "./plugin/set_magic_quotes_gpc_off/set_magic_quotes_gpc_off.php";
$pdo=$args[0];
$call=$method;
$class=__CLASS__;
$method=$class."::".$method;
require './program/'.self::$config['class_name'].'/receive/'.$call.'.php';
}
}
?>3数据展示处理文件 show/add.php
<?php
$_SESSION['token'][$method]=get_random(8);$module['action_url']="receive.php?token=".$_SESSION['token'][$method]."&target=".$method;
$module['monxin_table_name']=self::$language['functions'][str_replace("::",".",$method)]['description'];
$module['module_name']=str_replace("::","_",$method);
$module['class_name']=self::$config['class_name'];
//业务逻辑区
$t_path='./templates/'.$m_require_login.'/'.$class.'/'.self::$config['program']['template_'.$m_require_login].'/'.$_COOKIE['monxin_device'].'/'.str_replace($class."::","",$method).'.php';
if(!is_file($t_path)){$t_path='./templates/'.$m_require_login.'/'.$class.'/'.self::$config['program']['template_'.$m_require_login].'/pc/'.str_replace($class."::","",$method).'.php';}
require($t_path);
4数据接收处理文件receive/add.php
<?php
$post=safe_str($_POST);
$get=safe_str($_GET);
if(isset($get['add'])){
$sql="insert into ".self::$table_pre."table_name (`filed1`,`filed2`) values ('".$post['v1']."','".$post['2']."')";
if($pdo->exe($sql)){
exit("{'state':'success','info':'<span class=success>".self::$language['success']."</span><script>window.location.href=\"index.php?monxin=".self::$config['class_name'].".goods&id=".$insret_id."\";</script>'}");
}else{
exit("{'state':'fail','info':'<span class=fail>".self::$language['fail']."</span>'}");
}
}5模板文件美观处理 templates/add.php
<div id=<?php echo $module['module_name'];?> class="portlet light" monxin-module="<?php echo $module['module_name'];?>" align=left >
<!--
可调PHP变量组有 sell::$language $module, 建议临时var_dump输出下,有哪些键值可用;
此页,仅可使用PHP语句有 if else echo
-->
<script>
$(document).ready(function(){
$("#<?php echo $module['module_name'];?> .submit").click(function(){
//检证需求填写完整后,提交后台
$.get('<?php echo $module['action_url'];?>&act=update',obj, function(data){
try{v=eval("("+data+")");}catch(exception){alert(data);}
$("#<?php echo $module['module_name'];?> #state_"+id).html(v.info);
if(v.state=='success'){
}else{
}
});
return false;
});
});
</script>
<style>
#<?php echo $module['module_name'];?>{}
#<?php echo $module['module_name'];?>_html{ }
</style>
<div id="<?php echo $module['module_name'];?>_html">
html内容区
</div>
</div>
6示例下载
数据展示类 dirname.class.php数据接收处理类 receive.class.php数据展示处理文件 show/add.php数据接收处理文件receive/add.php模板文件美观处理 templates/add.php示例下载
本页由《梦行文档》生成

