当前位置: 网学 > 编程文档 > PHP > 正文

PHP中MVC模式的模板引擎开发经验分享

来源:Http://myeducs.cn 联系QQ:点击这里给我发消息 作者: 用户投稿 来源: 网络 发布时间: 13/06/21
etData($attr, $html, $list=false) {
if (!empty($attr)) {
$attr_ins = new Attbt($attr);
$attr_arr = $attr_ins->attrs;
if (is_array($attr_arr)) {
extract($attr_arr, EXTR_OVERWRITE);
$source = table_name($source, $column);
$rule = ''\[field:\s*(\w+)\s*([^\]]*?)\s*\/?]'';
preg_match_all(''/''.$rule.''/is'', $html, $out_matches);
$data_str = '''';
$data_ins = new DataSql();
$attr_where = $attr_order = '''';
if (!empty($where)) {
$where = str_replace('','', '' and '', $where);
$attr_where = '' where ''. $where;
}
if (!empty($order)) {
$attr_order = '' order by ''.$order;
} else {
$fed_name = '''';
$fed_ins = $data_ins->GetFedNeedle($source);
$fed_cnt = $data_ins->GetFedCount($fed_ins);
for ($i = 0; $i < $fed_cnt; $i ++) {
$fed_flag = $data_ins->GetFedFlag($fed_ins, $i);
if (preg_match(''/auto_increment/ism'', $fed_flag)) {
$fed_name = $data_ins->GetFedName($fed_ins, $i);
break;
}
}
if (!empty($fed_name))
$attr_order = '' order by ''.$fed_name.'' desc'';
}
if ($list == true) {
if (empty($source) && empty($sql)) {
exit(''标签{list}必须指定source属性!'');
}
$attr_rows = $attr_page = '''';
if ($rows > 0) {
$attr_rows = '' limit 0,''.$rows;
}
if (!empty($sql)) {
$data_sql = $sql;
} else {
$data_sql = ''select * from `''.$source.''`''.
$attr_where.$attr_order.$attr_rows;
}
if ($pages==''true'' && !empty($size)) {
$data_num = $data_ins->GetRecNum($data_sql);
$page_cnt = ceil($data_num / $size);
global $page;
if (!isset($page) || $page < 1) $page = 1;
if ($page > $page_cnt) $page = $page_cnt;
$data_sql = ''select * from `''.$source.''`''.$attr_where.
$attr_order.'' limit ''.($page-1) * $size.'',''.$size;
$GLOBALS[''cfg_page_curr''] = $page;
$GLOBALS[''cfg_page_prev''] = $page - 1;
$GLOBALS[''cfg_page_next''] = $page + 1;
$GLOBALS[''cfg_page_nums''] = $page_cnt;
if (function_exists(''list_pagelink'')) {
$GLOBALS[''cfg_page_list''] = list_pagelink($page, $page_cnt, 2);
}
}
$data_idx = 0;
$data_ret = $data_ins->SqlCmdExec($data_sql);
while ($row = $data_ins->GetRecArr($data_ret)) {
if ($skip > 0 && !empty($flag)) {
$data_idx != 0 &&
$data_idx % $skip == 0 &&
$data_str .= $flag;
}
$data_tmp = $html;
$data_tmp = str_ireplace(''@idx'', $data_idx, $data_tmp);
for ($i = 0; $i < count($out_matches[0]); $i ++) {
$data_tmp = str_ireplace($out_matches[0][$i],
$row[$out_matches[$i]], $data_tmp);
}
$data_str .= $data_tmp; $data_idx ++;
}
} else {
if (empty($source)) {
exit(''标签{data}必须指定source属性!'');
}
$data_sql = ''select * from `''.$source.
''`''.$attr_where.$attr_order;
$row = $data_ins->GetOneRec($data_sql);
if (is_array($row)) {
$data_tmp = $html;
for ($i = 0; $i < count($out_matches[0]); $i ++) {
$data_val = $row[$out_matches[$i]];
if (empty($out_matches[$i])) {
$data_tmp = str_ireplace($out_matches[0][$i], $data_val, $data_tmp);
} else {
$attr_str = $out_matches[$i];
$attr_ins = new Attbt($attr_str);
$func_txt = $attr_ins->attrs[''function''];
if (!empty($func_txt)) {
$func_tmp = explode(''('', $func_txt);

网学推荐

免费论文

原创论文

浏览:
设为首页 | 加入收藏 | 论文首页 | 论文专题 | 设计下载 | 网学软件 | 论文模板 | 论文资源 | 程序设计 | 关于网学 | 站内搜索 | 网学留言 | 友情链接 | 资料中心
版权所有 QQ:3710167 邮箱:3710167@qq.com 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
Copyright 2008-2015 myeducs.Cn www.myeducs.Cn All Rights Reserved
湘ICP备09003080号